GPU monitoring

Monitor and collect GPU metrics including utilization, memory usage, temperature, and process information.

source

get_gpu_info

 get_gpu_info ()

Check for GPU availability and get info using nvitop.

get_gpu_info()
{'available': True,
 'type': 'NVIDIA',
 'details': {'gpu_0': {'name': 'NVIDIA GeForce RTX 4090',
   'memory_total': 24564,
   'memory_used': 1787,
   'memory_free': 22282,
   'utilization': 8,
   'temperature': 44,
   'power_usage': 21.297,
   'power_limit': 450.0,
   'fan_speed': 0,
   'compute_processes': 7,
   'encoder_utilization': 0,
   'decoder_utilization': 0}},
 'processes': [{'pid': 5223,
   'name': '/usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -nolisten tcp -background none -noreset -keeptty -novtswitch -verbose 3',
   'gpu_memory_mb': 513,
   'gpu_utilization': 0,
   'device_id': 0,
   'device_name': 'NVIDIA GeForce RTX 4090'},
  {'pid': 5452,
   'name': '/usr/bin/gnome-shell',
   'gpu_memory_mb': 62,
   'gpu_utilization': 3,
   'device_id': 0,
   'device_name': 'NVIDIA GeForce RTX 4090'},
  {'pid': 11539,
   'name': '/usr/bin/nautilus --gapplication-service',
   'gpu_memory_mb': 17,
   'gpu_utilization': 0,
   'device_id': 0,
   'device_name': 'NVIDIA GeForce RTX 4090'},
  {'pid': 11782,
   'name': '/proc/self/exe --type=gpu-process --disable-gpu-sandbox --no-sandbox --enable-crash-reporter=94bcc087-1c49-442f-93c6-80a5155613d1,no_channel --user-data-dir=/home/innom-dt/.config/Code --gpu-preferences=UAAAAAAAAAAgAAAEAAAAAAAAAAAAAAAAAABgAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAABAAAAAAAAAAEAAAAAAAAAAIAAAAAAAAAAgAAAAAAAAA --shared-files --field-trial-handle=3,i,11272903268968390665,6950229763176126348,262144 --enable-features=DocumentPolicyIncludeJSCallStacksInCrashReports,EarlyEstablishGpuChannel,EstablishGpuChannelAsync --disable-features=CalculateNativeWinOcclusion,FontationsLinuxSystemFonts,ScreenAIOCREnabled,SpareRendererForSitePerProcess --variations-seed-version',
   'gpu_memory_mb': 84,
   'gpu_utilization': 0,
   'device_id': 0,
   'device_name': 'NVIDIA GeForce RTX 4090'},
  {'pid': 13731,
   'name': '/usr/share/typora/Typora --type=zygote --no-zygote-sandbox',
   'gpu_memory_mb': 25,
   'gpu_utilization': 0,
   'device_id': 0,
   'device_name': 'NVIDIA GeForce RTX 4090'},
  {'pid': 14235,
   'name': '/snap/firefox/6933/usr/lib/firefox/firefox',
   'gpu_memory_mb': 904,
   'gpu_utilization': 0,
   'device_id': 0,
   'device_name': 'NVIDIA GeForce RTX 4090'},
  {'pid': 58239,
   'name': '/usr/bin/gnome-text-editor /mnt/SN850X_8TB_EXT4/Projects/GitHub/cj-mills/cjm-fasthtml-sysmon/nbs/core/html_ids.ipynb',
   'gpu_memory_mb': 15,
   'gpu_utilization': 0,
   'device_id': 0,
   'device_name': 'NVIDIA GeForce RTX 4090'}]}