1. 程式人生 > >Linux檢視GPU資訊和使用情況

Linux檢視GPU資訊和使用情況

Linux檢視顯示卡資訊:

lspci | grep -i vga


使用nvidia GPU可以:

lspci | grep -i nvidia

 

[[email protected] ~]# lspci | grep -i nvidia
02:00.0 VGA compatible controller: NVIDIA Corporation Device 1b06 (rev a1)
02:00.1 Audio device: NVIDIA Corporation Device 10ef (rev a1)
03:00.0 VGA compatible controller: NVIDIA Corporation Device 1b06 (rev a1)
03:00.1 Audio device: NVIDIA Corporation Device 10ef (rev a1)
82:00.0 VGA compatible controller: NVIDIA Corporation Device 1b06 (rev a1)
82:00.1 Audio device: NVIDIA Corporation Device 10ef (rev a1)
83:00.0 VGA compatible controller: NVIDIA Corporation Device 1b06 (rev a1)
83:00.1 Audio device: NVIDIA Corporation Device 10ef (rev a1)

  

前邊的序號 "00:0f.0"是顯示卡的代號(這裡是用的虛擬機器);

檢視指定顯示卡的詳細資訊用以下指令:


lspci -v -s 00:0f.0

Linux檢視Nvidia顯示卡資訊及使用情況

Nvidia自帶一個命令列工具可以檢視視訊記憶體的使用情況:


nvidia-smi

 

[[email protected] ~]# nvidia-smi
Tue Nov 27 00:20:51 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.98                 Driver Version: 384.98                    |
|-------------------------------+----------------------+----------------------+
| 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...  On   | 00000000:02:00.0 Off |                  N/A |
| 66%   85C    P2   175W / 250W |  10795MiB / 11172MiB |    100%      Default |
+-------------------------------+----------------------+----------------------+
|   1  GeForce GTX 108...  On   | 00000000:03:00.0 Off |                  N/A |
| 56%   83C    P2   162W / 250W |  10795MiB / 11172MiB |    100%      Default |
+-------------------------------+----------------------+----------------------+
|   2  GeForce GTX 108...  On   | 00000000:82:00.0 Off |                  N/A |
| 52%   82C    P2   250W / 250W |  10795MiB / 11172MiB |     90%      Default |
+-------------------------------+----------------------+----------------------+
|   3  GeForce GTX 108...  On   | 00000000:83:00.0 Off |                  N/A |
| 54%   83C    P2   126W / 250W |  10795MiB / 11172MiB |     82%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0     11161      C   python                                     10785MiB |
|    1     11161      C   python                                     10785MiB |
|    2     12049      C   python                                     10785MiB |
|    3     12049      C   python                                     10785MiB |

  


表頭釋義: 

Fan:顯示風扇轉速,數值在0到100%之間,是計算機的期望轉速,如果計算機不是通過風扇冷卻或者風扇壞了,顯示出來就是N/A; 
Temp:顯示卡內部的溫度,單位是攝氏度;
Perf:表徵效能狀態,從P0到P12,P0表示最大效能,P12表示狀態最小效能;
Pwr:能耗表示; 
Bus-Id:涉及GPU匯流排的相關資訊; 
Disp.A:是Display Active的意思,表示GPU的顯示是否初始化; 
Memory Usage:視訊記憶體的使用率; 
Volatile GPU-Util:浮動的GPU利用率;
Compute M:計算模式; 
下邊的Processes顯示每塊GPU上每個程序所使用的視訊記憶體情況。

 

如果要週期性的輸出顯示卡的使用情況,可以用watch指令實現:


watch -n 10 nvidia-smi
命令列引數-n後邊跟的是執行命令的週期,以s為單位。

 


---------------------
作者:-牧野-
來源:CSDN
原文:https://blog.csdn.net/dcrmg/article/details/78146797
版權宣告:本文為博主原創文章,轉載請附上博文連結!