torch.cuda.is_ Available() returns false

1, problem

after the torch gpu version is installed, torch.cuda.is_available() always returns False; But the execution of the torch. Backends. Cudnn. Enabled is TRUE.

execute nvidia-smi command without error, can display the driver information;

on the Internet, search the solution: execute the command:

sudo apt-get install nvidia-cuda-toolkit

still gives an error.

2, problem analysis

try various way, or still returns False, normal if installed correctly, return TRUE, the problem is that version of the problem, either a video card driver versions do not match, either install packages do not match.

3. Solution:

(1) method 1: update the video card driver. This method is risky and troublesome to operate, so it is not recommended.

(2) method two: find the corresponding version of cudatoolkit for installation: the specific version of each driver support, as follows:

https://docs.nvidia.com/deploy/cuda-compatibility/#binary-compatibility

installation method:

 conda install pytorch torchvision cudatoolkit=xxx(选择对应的版本) -c pytorch



Read More: