From 29c86fd24c509989d4ae1a0715b512db01aa7692 Mon Sep 17 00:00:00 2001 From: nebriv Date: Thu, 21 Jun 2018 11:01:53 -0400 Subject: [PATCH] Added Fan Percentage to gpu properties using nvmlDeviceGetFanSpeed(). Updated output text to include fan percentage. --- gpustat/core.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gpustat/core.py b/gpustat/core.py index 442251a..dbff030 100644 --- a/gpustat/core.py +++ b/gpustat/core.py @@ -107,6 +107,16 @@ def temperature(self): v = self.entry['temperature.gpu'] return int(v) if v is not None else None + @property + def fan(self): + """ + Returns the fan percentage of GPU as an integer, + or None if the information is not available. + """ + v = self.entry['fan'] + return int(v) if v is not None else None + + @property def utilization(self): """ @@ -190,6 +200,7 @@ def _repr(v, none_value='??'): reps = "%(C1)s[{entry[index]}]%(C0)s " \ "%(CName)s{entry[name]:{gpuname_width}}%(C0)s |" \ "%(CTemp)s{entry[temperature.gpu]:>3}'C%(C0)s, " \ + "%(C0)s{entry[fan]:>3} %%%(C0)s, " \ "%(CUtil)s{entry[utilization.gpu]:>3} %%%(C0)s" if show_power: @@ -296,6 +307,11 @@ def _decode(b): except N.NVMLError: temperature = None # Not supported + try: + fan = N.nvmlDeviceGetFanSpeed(handle) + except N.NVMLError: + fan = None # Not supported + try: memory = N.nvmlDeviceGetMemoryInfo(handle) # in Bytes except N.NVMLError: @@ -350,6 +366,7 @@ def _decode(b): 'uuid': uuid, 'name': name, 'temperature.gpu': temperature, + 'fan': fan, 'utilization.gpu': utilization.gpu if utilization else None, 'power.draw': power // 1000 if power is not None else None, 'enforced.power.limit': power_limit // 1000