Search code examples
cudacupy

How to select correct CUDA toolkit and cupy version + install on old GPU


I have an old GPU GTX 870m.

I installed cupy by instructions, but nothing worked. At the same time, CUDA toolkit was installed successfully.

I try to use conda to install cupy and pip to install specific wheel version. It didn't help.

Easy sample don't work

import cupy

x = cupy.arange(6).reshape(2, 3).astype('f')
print(x.sum(axis=1))here

It displayed an error about problems with the driver

File "cupy\cuda\function.pyx", line 1, in init cupy.cuda.function 
File "cupy\_core\_carray.pyx", line 1, in init cupy._core._carray 
File "cupy\_core\internal.pyx", line 1, in init cupy._core.internal 
File "cupy\cuda\memory.pyx", line 1, in init cupy.cuda.memory 

ImportError: DLL load failed while importing driver

conda info shows:

virtual packages : __cuda=10.1=0

nvcc --version shows info about latest version.


Solution

  • To correctly select the CUDA toolkit vesion you need:

    • Check the driver version
      • For Windows in C:\Program Files\NVIDIA Corporation\NVSMI run .\nvidia-smi.exe
      • There is important driver version and the CUDA version.
    +-----------------------------------------------------------------------------+
    | NVIDIA-SMI 426.00       Driver Version: 426.00       CUDA Version: 10.1     |
    |-------------------------------+----------------------+----------------------+
    .........
    
    • If available, you should update the driver. In my case, this is last.

    • On the releases page check the available versions of the CUDA toolkit (table 3)

      • You should find find the most accessible version of CUDA / check the desired version is available.
    CUDA Toolkit Toolkit Driver Version Windows x86_64 Driver Version
    CUDA 10.1 (10.1.105 general release, and updates) >= 418.96
    • You should find on this page the installer of the desired version and install

    • Type nvcc --version in the command line. Find a version, in my case it's 10.1.243

    • Install the appropriate cupy. I recommend using 'conda' because there is less headache.

    conda install -c conda-forge cupy cudatoolkit=10.1.243

    Should work.

    cupy depends on the version of CUDA toolkit, and it cannot be higher than the card driver allows.