ROCm SMI Python CLI: Fix Fan Speed Bug

The purpose of this patch is to fix a fan speed bug for --showfan.
This bug occurs when the current and/or maximum fan speeds are not
found by the LIB, which displayed an unclear error message.

Signed-off-by: Ori Messinger <Ori.Messinger@amd.com>
Change-Id: Ied06e460f22391238dd2d86572813e2a5a64f45b


[ROCm/amdsmi commit: 4f297bdeb3]
Этот коммит содержится в:
Ori Messinger
2021-01-20 02:30:44 -05:00
коммит произвёл Kent Russell
родитель 8d37749c05
Коммит a5fee40cbb
+7 -3
Просмотреть файл
@@ -181,12 +181,10 @@ def getFanSpeed(device):
ret = rocmsmi.rsmi_dev_fan_speed_get(device, sensor_ind, byref(fanLevel))
if rsmi_ret_ok(ret, device):
fl = fanLevel.value
ret = rocmsmi.rsmi_dev_fan_speed_max_get(device, sensor_ind, byref(fanMax))
if rsmi_ret_ok(ret, device):
fm = fanMax.value
if fm == 0:
if fl == 0 or fm == 0:
return (fl, fm) # to prevent division by zero crash
return (fl, round((float(fl) / float(fm)) * 100, 2))
@@ -1394,6 +1392,12 @@ def showCurrentFans(deviceList):
for device in deviceList:
(fanLevel, fanSpeed) = getFanSpeed(device)
fanSpeed = round(fanSpeed)
if fanLevel == 0 or fanSpeed == 0:
printLog(device, 'Unable to detect fan speed for GPU %d' % (device), None)
logging.debug('Current fan speed is: %d\n' % (fanSpeed) + \
' Current fan level is: %d\n' % (fanLevel) + \
' (GPU might be cooled with a non-PWM fan)')
continue
if PRINT_JSON:
printLog(device, 'Fan speed (level)', str(fanLevel))
printLog(device, 'Fan speed (%)', str(fanSpeed))