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

2024/10/10 12:16:46

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:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243

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:

./deviceQuery 
./deviceQuery Starting...CUDA Device Query (Runtime API) version (CUDART static linking)Detected 1 CUDA Capable device(s)Device 0: "NVIDIA GeForce RTX 2080 Super with Max-Q Design"CUDA Driver Version / Runtime Version          11.4 / 11.4CUDA Capability Major/Minor version number:    7.5Total amount of global memory:                 7974 MBytes (8361279488 bytes)(048) Multiprocessors, (064) CUDA Cores/MP:    3072 CUDA CoresGPU Max Clock rate:                            1080 MHz (1.08 GHz)Memory Clock rate:                             5501 MhzMemory Bus Width:                              256-bitL2 Cache Size:                                 4194304 bytesMaximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layersMaximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layersTotal amount of constant memory:               65536 bytesTotal amount of shared memory per block:       49152 bytesTotal shared memory per multiprocessor:        65536 bytesTotal number of registers available per block: 65536Warp size:                                     32Maximum number of threads per multiprocessor:  1024Maximum number of threads per block:           1024Max dimension size of a thread block (x,y,z): (1024, 1024, 64)Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)Maximum memory pitch:                          2147483647 bytesTexture alignment:                             512 bytesConcurrent copy and kernel execution:          Yes with 3 copy engine(s)Run time limit on kernels:                     YesIntegrated GPU sharing Host Memory:            NoSupport host page-locked memory mapping:       YesAlignment requirement for Surfaces:            YesDevice has ECC support:                        DisabledDevice supports Unified Addressing (UVA):      YesDevice supports Managed Memory:                YesDevice supports Compute Preemption:            YesSupports Cooperative Kernel Launch:            YesSupports MultiDevice Co-op Kernel Launch:      YesDevice PCI Domain ID / Bus ID / location ID:   0 / 1 / 0Compute Mode:< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.4, CUDA Runtime Version = 11.4, NumDevs = 1
Result = PASS

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:

lrwxrwxrwx  1 root root   22 Oct  7 11:33 cuda -> /etc/alternatives/cuda/
lrwxrwxrwx  1 root root   25 Oct  7 11:33 cuda-11 -> /etc/alternatives/cuda-11/
drwxr-xr-x 16 root root 4096 Oct  7 11:33 cuda-11.4/

Is that normal?

Thanks for your help.

Answer

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 your environment. In fact, you don't even need to install CUDA on your system to use PyTorch with CUDA support.

https://en.xdnf.cn/q/118457.html

Related Q&A

How to have 2 advertisements in BLE(BlueTooth Low Energy)?

Im working on BLE advertisement. Id like to know if its possible to have 2 advertisements in BLE. I need to have both service data and manufacturer data. Im using Python. The code is based on https://g…

How to get Python script to write to existing sheet

I am writing a Python script and stuck on one of the early steps. I am opening an existing sheet and want to add two columns so I have used this:#import the writer import xlwt #import the reader impor…

Python3 - getting the sum of a particular row from all the files [closed]

Closed. This question needs debugging details. It is not currently accepting answers.Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to repro…

Selenium Headers in Python

how can I change my headers in Selenium like I do in requests ,I want to change my cookies and headers . from myCookie import cookie from selenium import webdriver from selenium.webdriver.common.by imp…

Get unique groups from a set of group

I am trying to find unique groups in a column(here for letter column) from an excel file. The data looks like this:id letter1 A, B, D, E, F3 B, C2 B75 T54 K, M9 D, B23 B, D, A34 X, Y, Z67 X, Y12 E, D15…

Move and Rename files using Python

I have .xls files in a directory that i need to move to another directory and renamed. Those files are updated monthly and will have a different name each month. For instance the current name is Geoc…

AttributeError: StringVar object has no attribute encode

Im making a program to generate an encrypted qr from the message and password provided, but it keeps on returning the same error.I tried passing the value to other variablesmain.pyfrom tkinter import *…

Reading specific column from a csv file in python

I am writing some python code to practice for an exam in January. I need to read the second column into my code and print it out. If possible i also need to add data to specific columns. The code i hav…

Date Time Series wise grouping of data and distribution

I am trying the merge the datetime series with a repository data while grouping by name and summing the values. File1.csv Timeseries,Name,count 07/03/2015 06:00:00,Paris,100 07/03/2015 06:00:00,Paris,6…

Trying to run Python in html

I am trying to run a python program in html but I am getting an error. First it says Then if I type anything it appears with this error This was the Html code <html><head><title>Antho…