Search code examples
pythoncupy

Does cupy automatically use cuda and the gpu?


I know that with other libraries that allow one to use python with the GPU, you have to specify that you're using cuda, otherwise the functions will work but not use cuda, like numba. Is the same true for cupy, or does it automatically use the GPU?


Solution

  • Yes, CuPy automatically uses CUDA.

    Before you install CuPy, you need to setup your CUDA environment. Then, you can install CuPy with a specific CUDA version as follows:

    pip install cupy-cudaXX
    

    where XX corresponds to your CUDA version, for example cupy-cuda90 for CUDA 9.0. See https://docs-cupy.chainer.org/en/stable/install.html#install-cupy for details.