Torch.cuda.is_available() is false CUDA Version: 11.4

Dear all,

I know that the question has been asked already several times, but the answers given seem not to help in my case. I cannot us cuda in my python scripts, I get torch.cuda.is_available() == False. I have installed pytorch and the cuda_toolkit using the following command:
conda install pytorch torchvision torchaudio cudatoolkit=11.4 -c pytorch -c nvidia

My output of nvidia-smi is:
±----------------------------------------------------------------------------+
| NVIDIA-SMI 470.57.02 Driver Version: 470.57.02 CUDA Version: 11.4 |
|-------------------------------±---------------------±---------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce … On | 00000000:01:00.0 Off | N/A |
| 30% 45C P8 41W / 420W | 163MiB / 24259MiB | 0% Default |
| | | N/A |
±------------------------------±---------------------±---------------------+
| 1 NVIDIA GeForce … On | 00000000:21:00.0 Off | N/A |
| 30% 46C P8 16W / 350W | 5MiB / 24268MiB | 0% Default |
| | | N/A |
±------------------------------±---------------------±---------------------+
| 2 NVIDIA GeForce … On | 00000000:4C:00.0 Off | N/A |
| 30% 38C P8 20W / 350W | 5MiB / 24268MiB | 0% Default |
| | | N/A |
±------------------------------±---------------------±---------------------+

±----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1741 G /usr/lib/xorg/Xorg 138MiB |
| 0 N/A N/A 2360 G cinnamon 23MiB |
| 1 N/A N/A 1741 G /usr/lib/xorg/Xorg 4MiB |
| 2 N/A N/A 1741 G /usr/lib/xorg/Xorg 4MiB |
±----------------------------------------------------------------------------+
Thanks in advance for any help

1 Like

It’d be best to get a dev’s opinion on this, but I believe pytorch only supports up to 11.1 as can be seen on their install page, Start Locally | PyTorch . So, perhaps it’s not supported yet?

I’ve just checked mine, and I’m running with CUDA version 11.2! (which works) So, maybe that’s the most recent supported version

1 Like

Thanks for your answer.
I’ve tried the 11.1 version and even if it don’t matches the version on my Nvidia GPU the problem is now solved.

1 Like

While I’m still learning about these versions - the Nvidia GPU version of CUDA must not be confused with the compatible version with PyTorch. You can look at the CUDA version for the GPU as the best allowed version.

Does your GPU support up to x.x version of CUDA? Then use the y.y PyTorch compatible version of CUDA up to that x.x version.

Hello, I upgraded nvidia-driver today. This are the driver details:
NVIDIA-SMI 470.82.00 Driver Version: 470.82.00 CUDA Version: 11.4

the pytorch setup with cu113 is working and shows cuda.is_available as True.

1 Like

JFYI, nvidia-smi gives you a highest version of cuda which is supported by GPU.
use nvcc -V command for a version that is running actually.

2 Likes

I believe nvidia-smi indicates the driver install version and CUDA version packaged with the driver. Note that the version used by PyTorch is determined by what CUDA version is packaged with the PyTorch binaries.

This saved me! On my computer, nvidia-smi returned 11.4 and I kept trying torch 11.3 but it didn’t use GPU. nvcc -V gave me 10.2 and installing torch 10.2 works great! Thanks!