본문 바로가기

Dev Platform/Linux

[Ubuntu] GPU 사용 확인하기

반응형

 

우분투에서 GPU 사용량 등을 확인하고 싶을 때 사용하는 툴을 소개합니다.

1. nvidia-smi

NAME

       nvidia-smi - NVIDIA System Management Interface program

SYNOPSIS>

       nvidia-smi [OPTION1 [ARG1]] [OPTION2 [ARG2]] ...

TIP : watch -n 0.5 nvidia-smi

 - 0.5초마다 nvidia-smi 호출

 

 

 

2. gpustat

Link : https://github.com/wookayin/gpustat

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

  • -p, --show-pid : Display PID of the process

  • -P, --show-power : Display GPU power usage and/or limit (draw or draw,limit)

  • -i, --interval : Run in watch mode (equivalent to watch gpustat) if given. Denotes interval between updates.

  • --json : JSON Output (Experimental, #10)

 

 

Tips :

  • To periodically watch, try gpustat -i (built-in watch support: #41). Alternative: watch --color -n1.0 gpustat --color << 매우 유용

  • Running nvidia-smi daemon (root privilege required) will make the query much faster.

  • The GPU ID (index) shown by gpustat (and nvidia-smi) is PCI BUS ID, while CUDA differently assigns the fastest GPU with the lowest ID by default. Therefore, in order to make CUDA and gpustat use same GPU index, configure the CUDA_DEVICE_ORDER environment variable to PCI_BUS_ID (before setting CUDA_VISIBLE_DEVICES for your CUDA program): export CUDA_DEVICE_ORDER=PCI_BUS_ID

반응형