Skip to content
Advertisement

Why are torch.version.cuda and deviceQuery reporting different versions?

I have a doubt about the CUDA version installed on my system and being effectively used by my software. I have done some research online but could not find a solution to my doubt. The issue which helped me a bit in my understanding and is the most related to what I will ask below is this one.

Description of the problem:

I created a virtualenvironment with virtualenvironmentwrapper and then I installed pytorch in it.

After some time I realized I did not have CUDA installed on my system.

You can find it out by doing:
nvcc –V

If nothing is returned it means that you did not install CUDA (as far as I understood).

Therefore, I followed the instructions here

And I installed CUDA with this official link.

Then, I installed the nvidia-development-kit simply with

sudo apt install nvidia-cuda-toolkit

Now, if in my virtualenvironment I do:

nvcc -V

I get:

JavaScript

However, if (always in the virtualenvironment) I do:

python -c "import torch; print(torch.version.cuda)"

I get:

10.2

This is the first thing I don’t understand. Which version of CUDA am I using in my virtualenvironment?

Then, if I run the sample deviceQuery (from the cuda-samples folder – the samples can be installed by following this link) I get:

JavaScript

Why is it now mentioned CUDA version 11.4? Is it because I am using the NVIDIA_CUDA-11.4_Samples I guess?

Another information is the following. If I check in my /usr/local folder I see three folders related to CUDA.

If I do:

cd /usr/local && ll | grep -i CUDA

I get:

JavaScript

Is that normal?

Thanks for your help.

Advertisement

Answer

torch.version.cuda is just defined as a string. It doesn’t query anything. It doesn’t tell you which version of CUDA you have installed. It only tells you that the PyTorch you have installed is meant for that (10.2) version of CUDA. But the version of CUDA you are actually running on your system is 11.4.

If you installed PyTorch with, say,

JavaScript

then you should also have the necessary libraries (cudatoolkit) in your Anaconda directory, which may be different from your system-level libraries.

However, note that these depend on the NVIDIA display drivers:

enter image description here

Installing cudatoolkit does not install the drivers (nvidia.ko), which you need to install separately on your system.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement