11.6 C
Jaipur
Wednesday, December 8, 2021

How to find the NVIDIA cuda version

Must read

I need to find out the CUDA version installed on Linux. How do I know what version of CUDA I have?

There are various ways and commands to check for the version of CUDA installed on Linux or Unix-like systems. Finding a version ensures that your application uses a specific feature or API. Hence, you need to get the CUDA version from the CLI.

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements NVIDIA with CUDA
Est. reading time 4 minutes

NOTE: You must have an NVIDIA card with a driver installed on Linux along with a CUDA toolkit too. If not, simply type the following apt/apt-get command to install the same:
sudo apt install nvidia-cuda-toolkit

Finding the NVIDIA cuda version

The procedure is as follows to check the CUDA version on Linux.

  1. Open the terminal application on Linux or Unix.
  2. Then type the nvcc --version command to view the version on screen:
  3. To check CUDA version use the nvidia-smi command:
  4. Finally you can query the /usr/lib/cuda/version.txt or /usr/local/cuda/version.txt as follows using the cat command to display the NVIDIA cuda version:
    cat /usr/lib/cuda/version.txt

How to get the CUDA version

Let us see all commands in details. The NVIDIA CUDA compiler is called nvcc and it print version information easily:
nvcc --version
Outputs from my Ubuntu Linux 20.04 LTS deskop:

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

Using nvidia-smi command for displaying the CUDA version

The nvidia-smi command provides monitoring and management capabilities for each of the following NVIDIA cards:

  • Tesla
  • Quadro
  • GRID
  • GeForce GPU from Fermi and higher architecture
  • Titan series GPU.

All you have to do is simply type the following command on your Linux or Unix terminal session:
nvidia-smi
Look for driver version line:

Thu Sep 30 14:23:23 2021       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.91.03    Driver Version: 460.91.03    CUDA Version: 11.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GTX 165...  Off  | 00000000:01:00.0  On |                  N/A |
| N/A   47C    P8     4W /  N/A |    894MiB /  3911MiB |      2%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
 
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      2734      G   /usr/lib/xorg/Xorg                100MiB |
|    0   N/A  N/A      3698      G   /usr/lib/xorg/Xorg                300MiB |
|    0   N/A  N/A      3916      G   /usr/bin/gnome-shell              122MiB |
|    0   N/A  N/A      4701      G   /usr/lib/firefox/firefox          246MiB |
|    0   N/A  N/A      4925      G   /usr/lib/firefox/firefox            1MiB |
|    0   N/A  N/A      5653      G   /usr/lib/firefox/firefox            1MiB |
|    0   N/A  N/A      5727      G   /usr/lib/firefox/firefox            1MiB |
|    0   N/A  N/A     14419      G   ...AAAAAAAAA= --shared-files       77MiB |
|    0   N/A  N/A     18778      G   ...AAAAAAAAA= --shared-files       27MiB |
|    0   N/A  N/A     19466      G   /usr/bin/nvidia-settings            1MiB |
+-----------------------------------------------------------------------------+

How do I know what version of CUDA I have insalled?

Finally, we can use the version.txt file. However, the location of this file changes. Hence use the find command or whereis command to locate the Cuda directory and then run the cat command as follows for printing required information on screen:
$ find /usr -type d -name cuda
/usr/lib/cuda
$ whereis cuda
cuda: /usr/lib/cuda /usr/include/cuda.h
$ cat /usr/lib/cuda/version.txt
CUDA Version 10.1.243

On a Debian or Ubuntu Linux one can use the dpkg command as follows too:
cat "$(dpkg -L nvidia-cuda-toolkit | grep 'version.txt')"

Patreon supporters only guides 🤓

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare
  • Join my Patreon to support independent content creators and start reading latest guides:

Join Patreon

Using package manger

Here is how to use the apt package manger to display installed version too:
apt info nvidia-cuda-toolkit
Look for Version:

Package: nvidia-cuda-toolkit
Version: 10.1.243-3
Priority: extra
Section: multiverse/devel
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Debian NVIDIA Maintainers <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 67.1 MB
Depends: nvidia-profiler (= 10.1.243-3), nvidia-cuda-dev (= 10.1.243-3), nvidia-opencl-dev (= 10.1.243-3) | opencl-dev, gcc-8 | clang-8 | clang-7 | gcc-7 | clang-6.0 | clang-5.0 | clang-4.0 | clang-3.9 | clang-3.8 | clang (<< 1:9~) | gcc-6 | gcc-5 | gcc-4.9 | gcc-4.8, g++-8 | clang-8 | clang-7 | g++-7 | clang-6.0 | clang-5.0 | clang-4.0 | clang-3.9 | clang-3.8 | clang (<< 1:9~) | g++-6 | g++-5 | g++-4.9 | g++-4.8, libc6 (>= 2.14), libgcc-s1 (>= 4.2), libstdc++6 (>= 4.1.1)
Recommends: nvidia-cuda-doc (= 10.1.243-3), nvidia-cuda-gdb (= 10.1.243-3), nvidia-visual-profiler (= 10.1.243-3), nsight-compute (= 10.1.243-3), nsight-systems (= 10.1.243-3)
Suggests: nvidia-driver (>= 418.39) | nvidia-tesla-440-driver (>= 418.39) | nvidia-tesla-418-driver (>= 418.39)
Conflicts: cuda-license-7-5, cuda-repo-ubuntu1404, cuda-repo-ubuntu1404-7-5-local, cuda-repo-ubuntu1410, cuda-repo-ubuntu1504, cuda-repo-ubuntu1504-7-5-local
Homepage: https://developer.nvidia.com/cuda-zone
Download-Size: 35.0 MB
APT-Manual-Installed: yes
APT-Sources: http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages
Description: NVIDIA CUDA development toolkit
 The Compute Unified Device Architecture (CUDA) enables NVIDIA
 graphics processing units (GPUs) to be used for massively parallel
 general purpose computation.
 .
 This package contains the nvcc compiler and other tools needed for building
 CUDA applications.
 .
 Running CUDA applications requires a supported NVIDIA GPU and the NVIDIA
 driver kernel module.

Summing up

You learned how to check the NVIDIA CUDA version on Linux or Unix using the command-line option. Knowing the CUDA toolkit assures that you have access to a specific feature or API. Hence, this tutorial exists. Do check the following man pages using the man command:
man nvcc
man nvidia-smi

Do check the NVIDIA developer website to grab the latest version of CUDA toolkit and read documentations.


ADVERTISEMENT

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -

Latest article