For debugging CUDA code and checking compatibilities I need to find out what nvidia driver version for the GPU I have installed. I found How to get the cuda version? but that does not help me here.
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 |
+-----------------------------------------------------------------------------+
-
2In my centos 6.4 system, it gives me error as "-bash: nvidia-smi: command not found". What might be the problem ? – Shyamkkhadka Mar 5 '17 at 10:03
-
@Shyamkkhadka Likely something wrong with your PATH. You could try to find
nvidia-smi
like so:locate nvidia-smi
– Brendan Wood Mar 10 '17 at 15:46 -
@BrendanWood, with locate command it shows blank output. I suspect if it has no gpu hardware either. Because it is HPC. And I am accessing it from remote, with ssh. – Shyamkkhadka Mar 10 '17 at 18:21
-
@Shyamkkhadka Yes, that's probably it. HPC generally don't have GPUs unless they are supposed to be a GPU cluster. You can check available hardware with
lspci
. For example: stackoverflow.com/questions/10310250/… – Brendan Wood Mar 10 '17 at 19:25 -
@BrendanWood, As suggested in your link, when I did "lspci | grep VGA". It shows output as "lspci | grep VGA 01:03.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] ES1000 (rev 02)". So I think it has GPU hardware. – Shyamkkhadka Mar 11 '17 at 21:22
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)
-
5Or if you have Bumblebee installed (due to NVIDIA Optimus dual GPU), then run this instead: "optirun cat /proc/driver/nvidia/version" – Shervin Emami Sep 7 '13 at 11:47
-
5This is especially useful when the output of
nvidia-smi
is:Failed to initialize NVML: GPU access blocked by the operating system
– DarioP Apr 24 '15 at 10:01 -
1In my centos 6.4 system, I don't have directory nvidia inside /proc/driver. What might be the problem ? Due to this, I am not able to see my nvidia driver version. – Shyamkkhadka Mar 5 '17 at 10:04
-
Also useful when you get the output
Failed to initialize NVML: Driver/library version mismatch
fromnvidia-smi
. – Sethos II Jul 10 '20 at 9:00
modinfo
does the trick.
root@nyx:/usr/src# modinfo nvidia|grep version:
version: 331.113
-
3On my system the module was named
nvidia_XXX
corresponding to the major driver series I had installed, and sincemodinfo
doesn't support wildcards or partial name matches I had to do thismodinfo $(find /lib/modules/$(uname -r) -iname nvidia_*.ko | head -1) | grep ^version:
which returns the correct major and minor driver version. – dragon788 Jul 12 '17 at 23:20 -
1On ubuntu 18.04 my version of
modinfo
has a--field
command line option. So you can skip the grep:modinfo nvidia --field version
. Also, in ubuntu 16.04 this doesn't seem to work. I always getERROR: Module nvidia not found
. – cheshirekow Jun 20 '19 at 20:38
Windows version:
cd \Program Files\NVIDIA Corporation\NVSMI
nvidia-smi
[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.
-
11That doesn't tell you what version of the driver is actually installed and in use by the kernel. Use the proc file system to see that.... Also this only works in debian style distributions. – talonmies Oct 29 '12 at 16:31
-
2@Framester thanks for leaving this up - that is the first thing that I'd have done (and its wrong!) – stephen Nov 9 '14 at 20:13
-
@Framester: You totally gamed the system! I just gave you another +1 on a useful wrong answer... you cunning devil :-) – einpoklum Apr 9 '17 at 20:35
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
-
this doesn't answer the question about driver version better than the accepted answer – JR Utily Sep 18 '18 at 18:30
-
1@JRUtily, thank you for the catch. I updated the code to show how to get the driver version. Cheers! – Jeff Blumenthal Sep 21 '18 at 17:24
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)