Ubuntu: How to measure GPU usage?



Question:

Using the top command in the terminal lists processes, sorted by their CPU usage (and you can change it to sort by another parameter)

Is there an equivalent for the GPU?

This fellow is asking about RAM used by GPU


Solution:1

For Nvidia GPUs there is a tool nvidia-smi that can show memory usage, GPU utilization and temperature of GPU.

For Intel GPU's you can use the intel-gpu-tools.

AMD has two options, fglrx (closed source drivers)

aticonfig --odgc --odgt  

And for mesa (open source drivers), you can use RadeonTop Install via the software center.

Source:GPU usage monitoring


Solution:2

Nvidia: to continuously update the output of nvidia-smi, you can use nvidia-smi --loop=1 (refresh interval of 1 second) or nvidia-smi --loop-ms=1000 (refresh interval of 1000 milliseconds).

   -l SEC, --loop=SEC         Continuously  report  query data at the specified interval, rather than         the default of  just  once.   The  application  will  sleep  in-between         queries.   Note  that on Linux ECC error or XID error events will print         out during the sleep period if the -x flag was not specified.  Pressing         Ctrl+C at any time will abort the loop, which will otherwise run indef‐         initely.  If no argument is specified for the -l form a default  inter‐         val of 5 seconds is used.       -lms ms, --loop-ms=ms         Same as -l,--loop but in milliseconds.  

FYI:


Solution:3

You can use gpustat, which is a simple command-line script (wrapper for nvidia-smi) for querying and monitoring GPU status:

enter image description here


Solution:4

You can use the monitoring program glances with its GPU monitoring plug-in:

  • open source
  • to install: sudo apt-get install -y python-pip; sudo pip install glances[gpu]
  • to launch: sudo glances

enter image description here

It also monitors the CPU, disk IO, disk space, network, and a few other things:

enter image description here


Solution:5

For Intel:

  1. Install intel-gpu-tools (its likely that they are installed already)

sudo apt-get install intel-gpu-tools

  1. Start the top like utility intel_gpu_top
  2. Check your Stats and then exit with <Ctrl+C>

Thats what you get:

enter image description here

Thanks @Mitch! :)


Solution:6

I use the following command:

nvidia-smi -l 2  

and it gives me updates every 2 seconds.

looks like this

Or :

watch -n0.1 "nvidia-settings -q GPUUtilization -q useddedicatedgpumemory"  

And on AMD, use:

aticonfig --odgc --odgt  

enter image description here


Solution:7

Conky

I like to use conky as a real-time monitor for both CPU and GPU. In this instance I've booted using the integrated GPU rather than the nVidia GTX 970M:

Intel GPU.gif

The conky code adapts depending on if booted with prime-select intel or prime-select nvidia:

#------------+  # Nvidia GPU |  #------------+  ${color orange}${hr 1}${if_existing /tmp/nvidia}  ${color2}${voffset 5}${execpi .001 (nvidia-smi --query-gpu=gpu_name --format=csv,noheader)} ${color}@ ${color green}${execpi .001 (nvidia-smi --query-gpu=clocks.sm --format=csv,noheader)} ${alignr}${color}Temp: ${color green}${execpi .001 (nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader)} C  ${color}${voffset 5}Ver: ${color green}${execpi .001 (nvidia-smi --query-gpu=driver_version --format=csv,noheader)} ${color} P-State: ${color green}${execpi .001 (nvidia-smi --query-gpu=pstate --format=csv,noheader)} ${alignr}${color}BIOS: ${color green}${execpi .001 (nvidia-smi --query-gpu=vbios_version --format=csv,noheader)}  ${color}${voffset 5}GPU:${color green}${execpi .001 (nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader)} ${color}Ram:${color green}${execpi .001 (nvidia-smi --query-gpu=utilization.memory --format=csv,noheader)} ${color}Pwr:${color green}${execpi .001 (nvidia-smi --query-gpu=power.draw --format=csv,noheader)} ${alignr}${color}Freq: ${color green}${execpi .001 (nvidia-smi --query-gpu=clocks.mem --format=csv,noheader)}  #------------+  # Intel iGPU |  #------------+  ${else}  ${color2}${voffset 5}Intel® Skylake GT2 HD 530 iGPU @  ${color green}${execpi .001 (cat /sys/class/drm/card0/gt_cur_freq_mhz)} MHz  ${color}${goto 13}Min. Freq:${goto 120}${color green}${execpi .001 (cat /sys/class/drm/card0/gt_min_freq_mhz)} MHz${color}${goto 210}Max. Freq:${alignr}${color green}${execpi .001 (cat /sys/class/drm/card0/gt_max_freq_mhz)} MHz  ${color orange}${hr 1}  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »