From 1db89fc9a8a0b060d06c997e7285358d50d2c39d Mon Sep 17 00:00:00 2001 From: Thomas Riccardi Date: Sun, 19 Aug 2012 19:42:14 +0200 Subject: [PATCH] nvidia_smi: Get memory usage even if nvmlDeviceGetUtilizationRates is not available --- plugins/gpu/nvidia_smi_ | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/gpu/nvidia_smi_ b/plugins/gpu/nvidia_smi_ index 1a9b389d..20817eed 100755 --- a/plugins/gpu/nvidia_smi_ +++ b/plugins/gpu/nvidia_smi_ @@ -110,7 +110,16 @@ for (my $i = 0; $i < $gpuCount; $i++) else { $gpuUtil = "N/A"; - $memUtil = "N/A"; + + ($ret, my $memory) = nvmlDeviceGetMemoryInfo($handle); + if ($ret == $NVML_SUCCESS) + { + $memUtil = $memory->{"used"} / $memory->{"total"} * 100; + } + else + { + $memUtil = "N/A"; + } } print "GPU_TEMP_$i.value $gpuTemp\n";