Would pytorch for cuda 11.6 work when cuda is actually 12.0

I will be using pytorch for a deep learning application. My computer has an NVIDIA GPU already.

I installed CUDA following CUDA Installation Guide for Microsoft Windows

Following that I installed pytorch in a conda environment with the pip command suggested on pytorch.org

pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116

However, when I check the CUDA version I installed with nvcc - version, I get

... Cuda compilation tools, release 12.0, V12.0.76 Build cuda_12.0.r12.0/compiler.31968024_0

My installation seems to be okay when I run the code torch.cuda.is_available()

as it returns True and identifies the name of the GPU, correctly.

Just wanted to check whether it is fool-proof when I actually feed in a deep learning model with a big dataset, since CUDA version is 12.0 but I installed pytorch suitable for 11.6.

Many thanks already.

Yes, your setup will work since the PyTorch binaries ship with their own CUDA runtime (as well as other CUDA libs such as cuBLAS, cuDNN, NCCL, etc.). The locally installed CUDA toolkit (12.0 in your case) will only be used if you are building PyTorch from source or a custom CUDA extension.
The NVIDIA drivers are backwards-compatible so the newer driver (I would guess 525.60) will also work.

1 Like

got it, thank you so much!