How to Check if Nvidia Driver Is Installed Ubuntu
Here you will learn how to check NVIDIA CUDA version in 3 ways: nvcc
from CUDA toolkit, nvidia-smi
from NVIDIA driver, and simply checking a file. Using one of these methods, you will be able to see the CUDA version regardless the software you are using, such as PyTorch, TensorFlow, conda (Miniconda/Anaconda) or inside docker.
Prerequisite
You should have NVIDIA driver installed on your system, as well as Nvidia CUDA toolkit, aka, CUDA, before we start. If you haven't, you can install it by running sudo apt install nvidia-cuda-toolkit
.
What is CUDA?
CUDA is a general parallel computing architecture and programming model developed by NVIDIA for its graphics cards (GPUs). Using CUDA, PyTorch or TensorFlow developers will dramatically increase the performance of PyTorch or TensorFlow training models, utilizing GPU resources effectively.
In GPU-accelerated technology, the sequential portion of the task runs on the CPU for optimized single-threaded performance, while the computed-intensive segment, like PyTorch technology, runs parallel via CUDA at thousands of GPU cores. When using CUDA, developers can write a few basic keywords in common languages such as C, C++ , Python, and implement parallelism.
Method 1 — Use nvcc
to check CUDA version
If you have installed the cuda-toolkit
software either from the official Ubuntu repositories via sudo apt install nvidia-cuda-toolkit
, or by downloading and installing it manually from the official NVIDIA website, you will have nvcc
in your path (try echo $PATH
) and its location will be /usr/bin/nvcc
(by running which nvcc
).
To check CUDA version with nvcc, run
nvcc --version
You can see similar output in the screenshot below. The last line shows you version of CUDA. The version here is 10.1. Yours may vary, and can be either 10.0, 10.1, 10.2 or even older versions such as 9.0, 9.1 and 9.2. After the screenshot you will find the full text output too.
vh@varhowto-com:~$ nvcc --version 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
What is nvcc?
nvcc
is the NVIDIA CUDA Compiler, thus the name. It is the key wrapper for the CUDA compiler suite. For other usage of nvcc
, you can use it to compile and link both host and GPU code.
Check out nvcc
's manpage for more information.
Method 2 — Check CUDA version by nvidia-smi
from NVIDIA Linux driver
The second way to check CUDA version is to run nvidia-smi, which comes from downloading the NVIDIA driver, specifically the NVIDIA-utils
package. You can install either Nvidia driver from the official repositories of Ubuntu, or from the NVIDIA website.
$ which nvidia-smi /usr/bin/nvidia-smi $ dpkg -S /usr/bin/nvidia-smi nvidia-utils-440: /usr/bin/nvidia-smi
To check CUDA version with nvidia-smi
, directly run
nvidia-smi
You can see similar output in the screenshot below. The version is at the top right of the output. Here's my version is CUDA 10.2. You may have 10.0, 10.1 or even the older version 9.0 or 9.1 or 9.2 installed.
Importantly, except for CUDA version. There are more details in the nvidia-smi output, driver version (440.100), GPU name, GPU fan percentage, power consumption/capability, memory usage, can also be found here. You can also find the processes which use the GPU at the moment. This is helpful if you want to see if your model or system is using GPU such as PyTorch or TensorFlow.
Here is the full text output:
vh@varhowto-com:~$ nvidia-smi Tue Jul 07 10:07:26 2020 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 440.100 Driver Version: 440.100 CUDA Version: 10.2 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce GTX 1070 Off | 00000000:01:00.0 On | N/A | | 31% 48C P0 35W / 151W | 2807MiB / 8116MiB | 1% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | 0 1582 G /usr/lib/xorg/Xorg 262MiB | | 0 2481 G /usr/lib/xorg/Xorg 1646MiB | | 0 2686 G /usr/bin/gnome-shell 563MiB | | 0 3244 G …AAAAAAAAAAAACAAAAAAAAAA= --shared-files 319MiB | +-----------------------------------------------------------------------------+
What is nvidia-smi?
nvidia-smi
(NVSMI) is NVIDIA System Management Interface program. It is also known as NVSMI. nvidia-smi
provides monitoring and maintenance capabilities for all of tje Fermi's Tesla, Quadro, GRID and GeForce NVIDIA GPUs and higher architecture families. For most functions, GeForce Titan Series products are supported with only little detail given for the rest of the Geforce range.
NVSMI is also a cross-platform application that supports both common NVIDIA driver-supported Linux distros and 64-bit versions of Windows starting with Windows Server 2008 R2. Metrics may be used directly by users via stdout, or stored via CSV and XML formats for scripting purposes.
For more information, check out the man
page of nvidia-smi
.
Method 3 — cat /usr/local/cuda/version.txt
cat /usr/local/cuda/version.txt
Note that if you install Nvidia driver and CUDA from Ubuntu 20.04's own official repository this approach may not work.
3 ways to check CUDA version
Time Needed : 5 minutes
There are basically three ways to check CUDA version. One must work if not the other.
- Perhaps the easiest way to check a file
Run
cat /usr/local/cuda/version.txt
Note: this may not work on Ubuntu 20.04
- Another method is through the
cuda-toolkit
package commandnvcc
.Simple run
nvcc --version
. The cuda version is in the last line of the output. - The other way is from the NVIDIA driver's
nvidia-smi
command you have installed.Simply run
nvidia-smi
. The version is in the header of the table printed.
How to Check if Nvidia Driver Is Installed Ubuntu
Source: https://varhowto.com/check-cuda-version/