Skip to content

Commit

Permalink
Nvidia GPU info #18
Browse files Browse the repository at this point in the history
  • Loading branch information
bkbilly committed Jan 21, 2023
1 parent 67128e6 commit 16d2ede
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions lnxlink/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@
- bash
- required_restart
- disk_usage
- nvidia_gpu
"""
24 changes: 24 additions & 0 deletions lnxlink/modules/nvidia_gpu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import subprocess


class Addon():
name = 'Nvidia GPU'
icon = 'mdi:expansion-card-variant'
unit = 'json'

def getInfo(self) -> dict:
stdout = subprocess.run(
['nvidia-smi',
'--query-gpu=driver_version,name,fan.speed,memory.total,memory.used,memory.free,utilization.gpu,utilization.memory,temperature.gpu,power.draw,clocks.current.graphics',
'--format=csv,nounits'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).stdout.decode("UTF-8").strip().split('\n')
# stdout = map(int, stdout.split(','))
headers = stdout[0].split(', ')
values = stdout[1].split(', ')

gpu_status = {}
for num, header in enumerate(headers):
gpu_status[header] = values[num]
gpu_status['status'] = gpu_status['name']
return gpu_status

0 comments on commit 16d2ede

Please sign in to comment.