Linux 如何从命令行获取 nvidia 驱动程序版本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13125714/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get the nvidia driver version from the command line?
提问by Framester
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.
为了调试 CUDA 代码和检查兼容性,我需要找出我安装的 GPU 的 nvidia 驱动程序版本。我找到了如何获取 cuda 版本?但这对我没有帮助。
采纳答案by Brendan Wood
Using nvidia-smi
should tell you that:
使用nvidia-smi
应该告诉你:
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 |
+-----------------------------------------------------------------------------+
回答by Framester
[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 notbe the version that is actually running as part of your kernel right now.
您将通过发行版的打包机制获得安装的 nVIDIA 驱动程序包的版本。但这可能不是现在作为内核的一部分实际运行的版本。
回答by talonmies
On anylinux system with the NVIDIA driver installed and loaded into the kernel, you can execute:
在任何安装了 NVIDIA 驱动程序并加载到内核中的 Linux 系统上,您都可以执行:
cat /proc/driver/nvidia/version
to get the version of the currently loaded NVIDIA kernel module, for example:
获取当前加载的 NVIDIA 内核模块的版本,例如:
$ 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)
回答by Michael
modinfo
does the trick.
modinfo
诀窍。
root@nyx:/usr/src# modinfo nvidia|grep version:
version: 331.113
回答by ccc
Windows version:
视窗版本:
cd \Program Files\NVIDIA Corporation\NVSMI
nvidia-smi
cd \Program Files\NVIDIA Corporation\NVSMI
英伟达-smi
回答by Martin Thoma
If you need to get that in a program with Python on a Linux system for reproducibility:
如果您需要在 Linux 系统上使用 Python 的程序中获得它以实现可重复性:
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)
回答by Jeff Blumenthal
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:
为了扩展 ccc 的答案,如果您想将查询卡与脚本结合起来,以下是 Nvidia 站点上有关如何执行此操作的信息:
https://nvidia.custhelp.com/app/answers/detail/a_id/3751/~/useful-nvidia-smi-queries
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.
另外,我发现这个线程正在研究 powershell。下面是一个示例命令,它运行该实用程序以获取 GPU 上可用的真实内存以帮助您入门。
# 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