From f3b32d05df1ca5e1a8550838d2adfc2b90a643d7 Mon Sep 17 00:00:00 2001 From: "Bill(Shuzhou) Liu" Date: Mon, 27 Feb 2023 08:01:15 -0600 Subject: [PATCH] mem_use_pct uninitialized error Initialize mem_use_pct if the memory info is not available. Change-Id: Id8e285050149c51077356826c8f99719b473060d [ROCm/amdsmi commit: fcb6afa28914b92777399bbc89f6c8ed2d6a9c05] --- projects/amdsmi/python_smi_tools/rocm_smi.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/projects/amdsmi/python_smi_tools/rocm_smi.py b/projects/amdsmi/python_smi_tools/rocm_smi.py index f99b7f3261..d682ab4490 100755 --- a/projects/amdsmi/python_smi_tools/rocm_smi.py +++ b/projects/amdsmi/python_smi_tools/rocm_smi.py @@ -1542,13 +1542,12 @@ def showAllConcise(deviceList): else: gpu_busy = 'Unsupported' memInfo = getMemInfo(device, 'vram') - if memInfo[0] == None or memInfo[1] == None or float(memInfo[1]) == 0: - mem_use = 'N/A' - else: + mem_use_pct = 0 + if memInfo[0] != None and memInfo[1] != None and float(memInfo[1]) != 0: mem_use_pct = '% 3.0f%%' % (100 * (float(memInfo[0]) / float(memInfo[1]))) values['card%s' % (str(device))] = [device, temp, avgPwr, sclk, mclk, fan, str(perf).lower(), pwrCap, mem_use_pct, gpu_busy] - val_widths = {} + val_widths = {} for device in deviceList: val_widths[device] = [len(str(val)) + 2 for val in values['card%s' % (str(device))]] max_widths = head_widths