Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to install cupy on google colab?

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/

like image 754
jusjosgra Avatar asked Mar 06 '18 15:03

jusjosgra


People also ask

How do I get CuPy version?

You can also install the development version of CuPy from a cloned Git repository: $ git clone https://github.com/cupy/cupy.git $ cd cupy $ pip install . If you are using source tree downloaded from GitHub, you need to install Cython 0.28. 0 or later ( pip install cython ).

Does CuPy automatically use GPU?

All that's required is a small snippet of your code in C++ format and CuPy will automatically do the GPU conversion, very similar to using Cython.

Does Google colab provide free GPU?

More technically, Colab is a hosted Jupyter notebook service that requires no setup to use, while providing access free of charge to computing resources including GPUs.


2 Answers

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 -
like image 124
kmaehashi Avatar answered Sep 18 '22 15:09

kmaehashi


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()
like image 45
TulakHord Avatar answered Sep 21 '22 15:09

TulakHord