Pytorch says that CUDA is not available Pytorch says that CUDA is not available linux linux

Pytorch says that CUDA is not available


PyTorch doesn't use the system's CUDA library. When you install PyTorch using the precompiled binaries using either pip or conda it is shipped with a copy of the specified version of the CUDA library which is installed locally. In fact, you don't even need to install CUDA on your system to use PyTorch with CUDA support.

There are two scenarios which could have caused your issue.

  1. You installed the CPU only version of PyTorch. In this case PyTorch wasn't compiled with CUDA support so it didn't support CUDA.

  2. You installed the CUDA 10.2 version of PyTorch. In this case the problem is that your graphics card currently uses the 418.87 drivers, which only support up to CUDA 10.1. The two potential fixes in this case would be to either install updated drivers (version >= 440.33 according to Table 2) or to install a version of PyTorch compiled against CUDA 10.1.

To determine the appropriate command to use when installing PyTorch you can use the handy widget in the "Install PyTorch" section at pytorch.org. Just select the appropriate operating system, package manager, and CUDA version then run the recommended command.

In your case one solution was to use

conda install pytorch torchvision cudatoolkit=10.1 -c pytorch

which explicitly specifies to conda that you want to install the version of PyTorch compiled against CUDA 10.1.

For more information about PyTorch CUDA compatibility with respect drivers and hardware see this answer.


Edit After you added the output of collect_env we can see that the problem was that you had the CUDA 10.2 version of PyTorch installed. Based on that an alternative solution would have been to update the graphics driver as elaborated in item 2 and the linked answer.