Home > other >  Python - how to use the chainer on Google colab switch from CPU to GPU?
Python - how to use the chainer on Google colab switch from CPU to GPU?

Time:12-07

I follow the instructions in the Chainer doc, it lead to when I was in running the code error:

RuntimeErrorTraceback (the most recent call last)
()
.
6 model=Classifier (CompetitionNetwork (n_units=64))
- & gt; 7 model. To_gpu ()
.
RuntimeError: CUDA environment is not correctly set up
(see https://github.com/chainer/chainer#installation). No module named cupy

Then I try to use many different ways to install cupy, one of which is

! Apt - y install libcusparse8.0 libnvrtc8.0 libnvtoolsext1
! Ln - SNF/usr/lib/x86_64 - - the gnu/Linux libnvrtc - builtins. So./usr/lib/x86_64-8.0 - the gnu/Linux libnvrtc - builtins. So
! PIP install cupy - cuda80 chainer

After import cupy then run my code to continue to give me the same error:

RuntimeError: CUDA environment is not correctly set up (see
https://github.com/chainer/chainer#installation). No module named cupy

Then I try to use the following method to install cuda:

! Wget cuda - https://developer.nvidia.com/compute/cuda/9.2/Prod/local_installers/cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64 - O '- ubuntu1604-9-2 - local_9. 2.88 1 _amd64. Deb

! DPKG -i cuda - '08 - ubuntu1604-9-2 - local_9. 2.88 1 _amd64. Deb

! Apt - the key to the add/var/cuda - '08 - & lt; Version>/7 fa2af80. Pub

! Apt to get the update

! Apt to get the install cuda

It took a long time, it seems to work but in the end still gave me the same error.
Seems to be used on Google Colab GPU Chainer is very difficult, unless I did wrong. Use Tensorflow, it is more easy. Does anyone have experience of using Chainer on Google GPU?

CodePudding user response:

You might want to look at this example Chainer.
https://colab.research.google.com/drive/1SsxHvQdSz23kaVov8yKizVD3_2tkXdZM

CodePudding user response:

Cuda version 10.0, install statement:
PIP install cupy - cuda100 has been solved
  • Related