How to check which CUDA version is installed on Linux ? (CUDA version)
如何检查 Linux 上安装的 CUDA 版本?
http://arnon.dk/
http://arnon.dk/check-cuda-installed/
There are several ways and steps you could check which CUDA version is installed on your Linux box.
您可以通过多种方法和步骤来检查 Linux 机箱上安装的 CUDA 版本。
1. Identify the CUDA location and version with NVCC
Run which nvcc
to find if NVCC is installed properly.
You should see something like /usr/bin/nvcc
. If that appears, your NVCC is installed in the standard directory.
yongqiang@strong-sys:~$ which nvcc
/usr/local/cuda-9.0/bin/nvcc
If you have installed the CUDA toolkit but which nvcc
returns no results, you might need to add the directory to your path.
You can check nvcc --version
to get the CUDA compiler version, which matches the toolkit version:
yongqiang@strong-sys:~$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176
yongqiang@strong-sys:~$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176
yongqiang@strong-sys:~$
This means that we have CUDA version 9.0.176 installed.
2. Identify CUDA version from CUDA code
Use the cudaDriverGetVersion()
API call. You can find an example of using cudaDriverGetVersion()
here.
3. Identifying which CUDA driver version is installed and active in the kernel
yongqiang@strong-sys:~$ cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module 390.48 Thu Mar 22 00:42:57 PDT 2018
GCC version: gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)
yongqiang@strong-sys:~$
yongqiang@strong-sys:~$ cat /usr/local/cuda/version.txt
CUDA Version 9.0.176
yongqiang@strong-sys:~$
yongqiang@strong-sys:~$ whereis cuda
cuda: /usr/local/cuda
4. Identifying which GPU card is installed and what version
Using nvidia-smi
is the best way I’ve found to get a holistic view of everything - both GPU card model and driver version.
使用 nvidia-smi
是我发现的最佳方式,可以全面了解所有内容 - 包括 GPU 卡型号和驱动程序版本。
holistic [həʊ'lɪstɪk; hɒ-]:adj. 整体的,全盘的
The driver version is 390.48 as seen below, and the cards are four GeForce 1080 Ti.
yongqiang@strong-sys:~$ nvidia-smi
Fri Oct 26 17:32:47 2018
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.48 Driver Version: 390.48 |
|-------------------------------+----------------------+----------------------+
| 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 108... Off | 00000000:02:00.0 On | N/A |
| 29% 27C P8 11W / 250W | 51MiB / 11177MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 1 GeForce GTX 108... Off | 00000000:03:00.0 Off | N/A |
| 29% 29C P8 8W / 250W | 2MiB / 11178MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 2 GeForce GTX 108... Off | 00000000:82:00.0 Off | N/A |
| 29% 25C P8 8W / 250W | 2MiB / 11178MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 3 GeForce GTX 108... Off | 00000000:83:00.0 Off | N/A |
| 29% 34C P8 9W / 250W | 2MiB / 11178MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 1276 G /usr/lib/xorg/Xorg 49MiB |
+-----------------------------------------------------------------------------+
yongqiang@strong-sys:~$
Troubleshooting (解决问题)
After installing a new version of CUDA, there are some situations that require rebooting the machine to have the driver versions load properly. It is my recommendation to reboot after performing the kernel-headers upgrade/install process, and after installing CUDA - to verify that everything is loaded correctly.
安装新版本的 CUDA 后,在某些情况下需要重新启动计算机才能正确加载驱动程序版本。我建议在执行 kernel-headers 升级/安装过程后重新启动,并在安装 CUDA 之后 - 验证是否所有内容都已正确加载。