From 98c92bb78facdf0d8456127a437d7fa4b2014839 Mon Sep 17 00:00:00 2001 From: Tom Saleeba Date: Sat, 24 Jul 2021 15:18:04 -0600 Subject: [PATCH] feat: add GPU usage % and GPU memory usage % to nvidiagpu --- bumblebee_status/modules/contrib/nvidiagpu.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bumblebee_status/modules/contrib/nvidiagpu.py b/bumblebee_status/modules/contrib/nvidiagpu.py index 4aa9de9..2731314 100644 --- a/bumblebee_status/modules/contrib/nvidiagpu.py +++ b/bumblebee_status/modules/contrib/nvidiagpu.py @@ -4,7 +4,7 @@ Parameters: * nvidiagpu.format: Format string (defaults to '{name}: {temp}°C %{usedmem}/{totalmem} MiB') - Available values are: {name} {temp} {mem_used} {mem_total} {fanspeed} {clock_gpu} {clock_mem} + Available values are: {name} {temp} {mem_used} {mem_total} {fanspeed} {clock_gpu} {clock_mem} {gpu_usage_pct} {mem_usage_pct} Requires nvidia-smi @@ -41,6 +41,8 @@ class Module(core.module.Module): clockMem = "" clockGpu = "" fanspeed = "" + gpuUsagePct = "" + memPct = "" for item in sp.split("\n"): try: key, val = item.split(":") @@ -61,6 +63,11 @@ class Module(core.module.Module): name = val elif key == "Fan Speed": fanspeed = val.split(" ")[0] + elif title == "Utilization": + if key == "Gpu": + gpuUsagePct = val.split(" ")[0] + elif key == "Memory": + memPct = val.split(" ")[0] except: title = item.strip() @@ -76,6 +83,8 @@ class Module(core.module.Module): clock_gpu=clockGpu, clock_mem=clockMem, fanspeed=fanspeed, + gpu_usage_pct=gpuUsagePct, + mem_usage_pct=memPct, )