Linux 查看GPU狀態
nvidia-smi
nvidia-smi
是NVIDIA自帶的一個命令可以詳細的展示顯卡的運行狀態。
gpustat
gpustat
是github上開源的一個小工具,對於v1.0
目前支持python 3.4+
,對於python 2.7-3.4
支持v0.x
。
可以直接用pip安裝
pip install gpustat
如果沒有root權限的話
pip install --user gpustat
如果沒有root權限,安裝完之后,可能需要添加環境變量。
export PATH=$PATH:/home/XXX/.local/bin
# XXX換成你的用戶名
使用命令
$ gpustat -options
Options:
--color
: Force colored output (even when stdout is not a tty)--no-color
: Suppress colored output-u
,--show-user
: Display username of the process owner-c
,--show-cmd
: Display the process name-f
,--show-full-cmd
: Display full command and cpu stats of running process-p
,--show-pid
: Display PID of the process-F
,--show-fan
: Display GPU fan speed-e
,--show-codec
: Display encoder and/or decoder utilization-P
,--show-power
: Display GPU power usage and/or limit (draw
ordraw,limit
)-a
,--show-all
: Display all gpu properties above--watch
,-i
,--interval
: Run in watch mode (equivalent towatch gpustat
) if given. Denotes interval between updates.--json
: JSON Output (Experimental)
$ gpustat
不帶任何參數,會顯示gpu的基本使用情況
$ gpustat -cp
顯示具體進程號和進程名
輸出實例解釋
[0] GeForce GTX Titan X | 77'C, 96 % | 11848 / 12287 MB | python/52046(11821M)
- [0]: GPUindex (starts from 0) as PCI_BUS_ID
- GeForce GTX Titan `: GPU name
- 77’C: Temperature
- 96 %: Utilization
- 11848 / 12287 MB: GPU Memory Usage
- python/...: Running processes on GPU (and their memory usage)
實時動態顯示
watch --color -n1 gpustat -cpu
結合watch可以動態實時的監控GPU的使用情況。