How to get the nvidia driver version from the command line?

LinuxCudaDriver

Linux Problem Overview


For debugging CUDA code and checking compatibilities I need to find out what nvidia driver version for the GPU I have installed. I found https://stackoverflow.com/questions/9727688/how-to-get-the-cuda-version but that does not help me here.

Linux Solutions


Solution 1 - Linux

Using nvidia-smi should tell you that:

bwood@mybox:~$ nvidia-smi 
Mon Oct 29 12:30:02 2012       
+------------------------------------------------------+                       
| NVIDIA-SMI 3.295.41   Driver Version: 295.41         |                       
|-------------------------------+----------------------+----------------------+
| Nb.  Name                     | Bus Id        Disp.  | Volatile ECC SB / DB |
| Fan   Temp   Power Usage /Cap | Memory Usage         | GPU Util. Compute M. |
|===============================+======================+======================|
| 0.  GeForce GTX 580           | 0000:25:00.0  N/A    |       N/A        N/A |
|  54%   70 C  N/A   N/A /  N/A |  25%  383MB / 1535MB |  N/A      Default    |
|-------------------------------+----------------------+----------------------|
| Compute processes:                                               GPU Memory |
|  GPU  PID     Process name                                       Usage      |
|=============================================================================|
|  0.           Not Supported                                                 |
+-----------------------------------------------------------------------------+

Solution 2 - Linux

On any linux system with the NVIDIA driver installed and loaded into the kernel, you can execute:

cat /proc/driver/nvidia/version

to get the version of the currently loaded NVIDIA kernel module, for example:

$ cat /proc/driver/nvidia/version 
NVRM version: NVIDIA UNIX x86_64 Kernel Module  304.54  Sat Sep 29 00:05:49 PDT 2012
GCC version:  gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) 

Solution 3 - Linux

modinfo does the trick.

root@nyx:/usr/src# modinfo nvidia|grep version:
version:        331.113

Solution 4 - Linux

Windows version:

>cd \Program Files\NVIDIA Corporation\NVSMI > >nvidia-smi

Solution 5 - Linux

[NOTE: I am not deleting my answer on purpose, so people see how not to do it]

If you use:

me@over_there:~$  dpkg --status nvidia-current | grep Version | cut -f 1 -d '-' | sed 's/[^.,0-9]//g'
260.19.06

you will get the version of the nVIDIA driver package installed through your distribution's packaging mechanism. But this may not be the version that is actually running as part of your kernel right now.

Solution 6 - Linux

To expand on ccc's answer, if you want to incorporate querying the card with a script, here is information on Nvidia site on how to do so:

https://nvidia.custhelp.com/app/answers/detail/a_id/3751/~/useful-nvidia-smi-queries

Also, I found this thread researching powershell. Here is an example command that runs the utility to get the true memory available on the GPU to get you started.

# get gpu metrics
$cmd = "& 'C:\Program Files\NVIDIA Corporation\NVSMI\nvidia-smi' --query-gpu=name,utilization.memory,driver_version --format=csv"
$gpuinfo = invoke-expression $cmd | ConvertFrom-CSV
$gpuname = $gpuinfo.name
$gpuutil = $gpuinfo.'utilization.memory [%]'.Split(' ')[0]
$gpuDriver = $gpuinfo.driver_version

Solution 7 - Linux

nvidia-smi --query-gpu=driver_version --format=csv,noheader --id=0

returns result as a string that doesn't require further parsing like: 470.82.00

In case nvidia-smi is not available for some reason, information can be obtained by calling into driver APIs. Driver libraries can be loaded using Python ctypes library.

For CUDA see: https://gist.github.com/f0k/63a664160d016a491b2cbea15913d549

For driver information see: https://github.com/mars-project/mars/blob/a50689cda4376d82a40b7aa9833f572299db7efd/mars/lib/nvutils.py

Solution 8 - Linux

If you need to get that in a program with Python on a Linux system for reproducibility:

with open('/proc/driver/nvidia/version') as f:
    version = f.read().strip()
print(version)

gives:

NVRM version: NVIDIA UNIX x86_64 Kernel Module  384.90  Tue Sep 19 19:17:35 PDT 2017
GCC version:  gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.5) 

Solution 9 - Linux

nvidia-container-cli info is one of the other commands. Below is an example of running my environment.

⋊> ~ nvidia-container-cli info                                               18:32:30
NVRM version:   465.19.01
CUDA version:   11.3

Device Index:   0
Device Minor:   0
Model:          NVIDIA TITAN X (Pascal)
Brand:          GeForce
GPU UUID:       GPU-fcae2b3c-b6c0-c0c6-1eef-4f25809d16f9
Bus Location:   00000000:01:00.0
Architecture:   6.1
⋊> ~                                                                         18:32:30

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFramesterView Question on Stackoverflow
Solution 1 - LinuxBrendan WoodView Answer on Stackoverflow
Solution 2 - LinuxtalonmiesView Answer on Stackoverflow
Solution 3 - LinuxMichaelView Answer on Stackoverflow
Solution 4 - LinuxcccView Answer on Stackoverflow
Solution 5 - LinuxFramesterView Answer on Stackoverflow
Solution 6 - LinuxJeff BlumenthalView Answer on Stackoverflow
Solution 7 - LinuxAleksey VlasenkoView Answer on Stackoverflow
Solution 8 - LinuxMartin ThomaView Answer on Stackoverflow
Solution 9 - LinuxKeikuView Answer on Stackoverflow