Is it possible to install cupy on google colab?

2019-06-06 19:09发布

I am trying to run chainer with GPU on google colab. This requires cupy installed however I fail to install this properly as it cannot find the cuda environment in my colab vm.

Error message as follows...

Collecting cupy Downloading cupy-2.4.0.tar.gz (1.7MB) 100% |████████████████████████████████| 1.7MB 740kB/s Complete output from command python setup.py egg_info: cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ /tmp/tmpds3ikncy/a.cpp:1:10: fatal error: cublas_v2.h: No such file or directory #include ^~~~~~~~~~~~~ compilation terminated. Options: {'profile': False, 'linetrace': False, 'annotate': False, 'no_cuda': False} ************************************************** * WARNING: nvcc not in path. * WARNING: Please set path to nvcc. ************************************************** Include directories: [] Library directories: [] command 'x86_64-linux-gnu-gcc' failed with exit status 1 ************************************************** * WARNING: Include files not found: ['cublas_v2.h', 'cuda.h', 'cuda_profiler_api.h', 'cuda_runtime.h', 'curand.h', 'cusparse.h', 'nvrtc.h', 'nvToolsExt.h'] * WARNING: Skip installing cuda support *** WARNING: Check your CFLAGS environment variable ************************************************** Traceback (most recent call last): File "", line 1, in File "/tmp/pip-build-qu5red9h/cupy/setup.py", line 32, in ext_modules = cupy_setup_build.get_ext_modules() File "/tmp/pip-build-qu5red9h/cupy/cupy_setup_build.py", line 385, in get_ext_modules extensions = make_extensions(arg_options, compiler, use_cython) File "/tmp/pip-build-qu5red9h/cupy/cupy_setup_build.py", line 275, in make_extensions raise Exception('Your CUDA environment is invalid. ' Exception: Your CUDA environment is invalid. Please check above error log.

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-qu5red9h/cupy/

2条回答
Emotional °昔
2楼-- · 2019-06-06 19:33

Edit: Google Colaboratory now provides Chainer, CuPy and iDeep by default. Manual installation is no longer necessary.


Original Answer:

You can use a wheel to avoid building CuPy by yourself on Google Colab. Chainer officially provides snippet to install Chainer/CuPy on Google Colab.

!curl https://colab.chainer.org/install | sh -
查看更多
仙女界的扛把子
3楼-- · 2019-06-06 19:33

We do not need to install cupy manually in Google colab. In Notebook Settings under Edit we can choose GPU. If you have chainer already installed you can confirm availability of cupy through this:

chainer.print_runtime_info()
查看更多
登录 后发表回答