Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Fan Percentage #42

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions gpustat/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down