From 4f297bdeb3786d9ccf88cbf3a31b95fc0632d3f2 Mon Sep 17 00:00:00 2001 From: Ori Messinger Date: Wed, 20 Jan 2021 02:30:44 -0500 Subject: [PATCH] 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 Change-Id: Ied06e460f22391238dd2d86572813e2a5a64f45b --- python_smi_tools/rocm_smi.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python_smi_tools/rocm_smi.py b/python_smi_tools/rocm_smi.py index e87a8c1c18..c6fedd4027 100755 --- a/python_smi_tools/rocm_smi.py +++ b/python_smi_tools/rocm_smi.py @@ -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))