[cuda] How to get the CUDA version?

Is there any quick command or script to check for the version of CUDA installed?

I found the manual of 4.0 under the installation directory but I'm not sure whether it is of the actual installed version or not.

This question is related to cuda

The answer is


Apart from the ones mentioned above, your CUDA installations path (if not changed during setup) typically contains the version number

doing a which nvcc should give the path and that will give you the version

PS: This is a quick and dirty way, the above answers are more elegant and will result in the right version with considerable effort


Use the following command to check CUDA installation by Conda:

conda list cudatoolkit

And the following command to check CUDNN version installed by conda:

conda list cudnn

If you want to install/update CUDA and CUDNN through CONDA, please use the following commands:

conda install -c anaconda cudatoolkit
conda install -c anaconda cudnn

Alternatively you can use following commands to check CUDA installation:

nvidia-smi

OR

nvcc --version

If you are using tensorflow-gpu through Anaconda package (You can verify this by simply opening Python in console and check if the default python shows Anaconda, Inc. when it starts, or you can run which python and check the location), then manually installing CUDA and CUDNN will most probably not work. You will have to update through conda instead.

If you want to install CUDA, CUDNN, or tensorflow-gpu manually, you can check out the instructions here https://www.tensorflow.org/install/gpu


Found mine after:

whereis cuda

at

cuda: /usr/lib/cuda /usr/include/cuda.h

with

nvcc --version

CUDA Version 9.1.85


i get /usr/local - no such file or directory. Though nvcc -V gives

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Sun_Sep__4_22:14:01_CDT_2016
Cuda compilation tools, release 8.0, V8.0.44

You could also use:

nvidia-smi | grep "CUDA Version:" 

To retrieve the explicit line.


On Ubuntu Cuda V8:

$ cat /usr/local/cuda/version.txt

First you should find where Cuda installed.

If it's a default installation like here the location should be:

for ubuntu:

/usr/local/cuda

in this folder you should have a file

version.txt

open this file with any text editor or run:

cat version.txt

from the folder

OR

 cat /usr/local/cuda/version.txt 

For CUDA version:

nvcc --version

Or use,

nvidia-smi

For cuDNN version:

For Linux:

Use following to find path for cuDNN:

$ whereis cuda
cuda: /usr/local/cuda

Then use this to get version from header file,

$ cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

For Windows,

Use following to find path for cuDNN:

C:\>where cudnn*
C:\Program Files\cuDNN7\cuda\bin\cudnn64_7.dll

Then use this to dump version from header file,

type "%PROGRAMFILES%\cuDNN7\cuda\include\cudnn.h" | findstr CUDNN_MAJOR

If you're getting two different versions for CUDA on Windows - Different CUDA versions shown by nvcc and NVIDIA-smi


You can check the version of CUDA using

nvcc -V

or you can use

nvcc --version

or You can check the location of where the CUDA is using

whereis cuda 

and then do

cat location/of/cuda/you/got/from/above/command

We have three ways to check Version: In my case below is the output:- Way 1:-

cat /usr/local/cuda/version.txt

Output:-

CUDA Version 10.1.243

Way2:-

nvcc --version

Output:-

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85

Way3:-

/usr/local/cuda/bin/nvcc --version

Output:-

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

Way4:-

nvidia-smi
NVIDIA-SMI 450.36.06    Driver Version: 450.36.06    CUDA Version: 11.0

Outputs are not same. Don't know why it's happening.


If there is a version mismatch between nvcc and nvidia-smi then different versions of cuda are used as driver and run time environemtn.

To ensure same version of CUDA drivers are used what you need to do is to get CUDA on system path.

First run whereis cuda and find the location of cuda driver.

Then go to .bashrc and modify the path variable and set the directory precedence order of search using variable 'LD_LIBRARY_PATH'.

for instance

$ whereis cuda
cuda: /usr/lib/cuda /usr/include/cuda.h /usr/local/cuda

CUDA is installed at /usr/local/cuda, now we need to to .bashrc and add the path variable as:

vim  ~/.bashrc
export PATH="/usr/local/cuda/bin:${PATH}"

and after this line set the directory search path as:

export LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH}"

Then save the .bashrc file. And refresh it as:

$ source ~/.bashrc

This will ensure you have nvcc -V and nvidia-smi to use the same version of drivers.


One can get the cuda version by typing the following in the terminal:

$ nvcc -V

# below is the result
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85

Alternatively, one can manually check for the version by first finding out the installation directory using:

$ whereis -b cuda         
cuda: /usr/local/cuda

And then cd into that directory and check for the CUDA version.


If you are running on linux:

dpkg -l | grep cuda

On Ubuntu :

Try

$ cat /usr/local/cuda/version.txt or $ cat /usr/local/cuda-8.0/version.txt

Sometimes the folder is named "Cuda-version".

If none of above works, try going to $ /usr/local/ And find the correct name of your Cuda folder.

Output should be similar to: CUDA Version 8.0.61


You might find CUDA-Z useful, here is a quote from their Site:

"This program was born as a parody of another Z-utilities such as CPU-Z and GPU-Z. CUDA-Z shows some basic information about CUDA-enabled GPUs and GPGPUs. It works with nVIDIA Geforce, Quadro and Tesla cards, ION chipsets."

http://cuda-z.sourceforge.net/

On the Support Tab there is the URL for the Source Code: http://sourceforge.net/p/cuda-z/code/ and the download is not actually an Installer but the Executable itself (no installation, so this is "quick").

This Utility provides lots of information and if you need to know how it was derived there is the Source to look at. There are other Utilities similar to this that you might search for.


Open a terminal and run these commands:

cd /usr/local/cuda/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery

You can get the information of CUDA Driver version, CUDA Runtime Version, and also detailed information for GPU(s). An image example of the output from my end is as below.

You can find the image here.


Programmatically with the CUDA Runtime API C++ wrappers:

auto v1 = cuda::version::maximum_supported_by_driver();
auto v2 = cuda::version::runtime();

This gives you a cuda::version_t structure, which you can compare and also stream, e.g.:

if (v2 < cuda::version_t{ 8, 0 } ) {
    std::cerr << "CUDA version " << v2 << " is insufficient." std::endl;
}

If you run

nvidia-smi

You should find the CUDA Version on the top right corner of the comand's output. At least I found that output for CUDA version 10.0 e.g., enter image description here


After installing CUDA one can check the versions by: nvcc -V

I have installed both 5.0 and 5.5 so it gives

Cuda Compilation Tools,release 5.5,V5.5,0

This command works for both Windows and Ubuntu.


if nvcc --version is not working for you then use cat /usr/local/cuda/version.txt


If you have installed CUDA SDK, you can run "deviceQuery" to see the version of CUDA