How to get the CUDA version?

On Ubuntu Cuda V8:

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

You can also get some insights into which CUDA versions are installed with:

$ ls -l /usr/local | grep cuda

which will give you something like this:

lrwxrwxrwx  1 root root    9 Mar  5  2020 cuda -> cuda-10.2
drwxr-xr-x 16 root root 4096 Mar  5  2020 cuda-10.2
drwxr-xr-x 16 root root 4096 Mar  5  2020 cuda-8.0.61

Given a sane PATH, the version cuda points to should be the active one (10.2 in this case).

NOTE: This only works if you are willing to assume CUDA is installed under /usr/local/cuda (which is true for the independent installer with the default location, but not true e.g. for distributions with CUDA integrated as a package). Ref: comment from @einpoklum.


[Edited answer. Thanks for everyone who corrected it]

If you run

nvidia-smi

You should find the CUDA Version highest CUDA version the installed driver supports 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


As Jared mentions in a comment, from the command line:

nvcc --version

(or /usr/local/cuda/bin/nvcc --version) gives the CUDA compiler version (which matches the toolkit version).

From application code, you can query the runtime API version with

cudaRuntimeGetVersion()

or the driver API version with

cudaDriverGetVersion()

As Daniel points out, deviceQuery is an SDK sample app that queries the above, along with device capabilities.

As others note, you can also check the contents of the version.txt using (e.g., on Mac or Linux)

cat /usr/local/cuda/version.txt

However, if there is another version of the CUDA toolkit installed other than the one symlinked from /usr/local/cuda, this may report an inaccurate version if another version is earlier in your PATH than the above, so use with caution.

Tags:

Cuda