From 4e97667f31a9fcf312e995c7c31e475365c89cf4 Mon Sep 17 00:00:00 2001 From: Ori Messinger Date: Thu, 15 Oct 2020 06:31:29 -0400 Subject: [PATCH] ROCm SMI Python CLI: Add CU Occupancy to showPids function The purpose of this patch is to add CU occupancy functionality to showPids by calling rsmi_compute_process_info_get from the LIB. Now showPids shows the following information on (KFD compute) processes: PID, process name, GPU(s), VRAM used, SDMA used, and CU occupancy. Change-Id: Ie005901e0eb946ef0fbb3523245ca451c4eed595 Signed-off-by: Ori Messinger [ROCm/rocm_smi_lib commit: 20ae72b0786c58408e66d67558f1e389ebfa55f6] --- projects/rocm-smi-lib/python_smi_tools/rocm_smi.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/projects/rocm-smi-lib/python_smi_tools/rocm_smi.py b/projects/rocm-smi-lib/python_smi_tools/rocm_smi.py index ed79d966e7..4522160e77 100755 --- a/projects/rocm-smi-lib/python_smi_tools/rocm_smi.py +++ b/projects/rocm-smi-lib/python_smi_tools/rocm_smi.py @@ -1517,7 +1517,7 @@ def showPids(): """ Show Information for PIDs created in a KFD (Compute) context """ printLogSpacer(' KFD Processes ') dataArray = [] - dataArray.append(['PID', 'PROCESS NAME', 'GPU(s)', 'VRAM USED', 'SDMA USED']) + dataArray.append(['PID', 'PROCESS NAME', 'GPU(s)', 'VRAM USED', 'SDMA USED', 'CU OCCUPANCY']) pidList = getPidList() if not pidList: printLog(None, 'No KFD PIDs currently running', None) @@ -1530,6 +1530,7 @@ def showPids(): gpuNumber = 'UNKNOWN' vramUsage = 'UNKNOWN' sdmaUsage = 'UNKNOWN' + cuOccupancy = 'UNKNOWN' ret = rocmsmi.rsmi_compute_process_gpus_get(int(pid), None, byref(num_devices)) if rsmi_ret_ok(ret): dv_indices = (c_uint32 * num_devices.value)() @@ -1537,14 +1538,15 @@ def showPids(): if rsmi_ret_ok(ret): gpuNumber = str(num_devices.value) else: - logging.debug('Unable to fetch PID GPU information') + logging.debug('Unable to fetch GPU number by PID') ret = rocmsmi.rsmi_compute_process_info_by_pid_get(int(pid), byref(proc)) if rsmi_ret_ok(ret): vramUsage = proc.vram_usage sdmaUsage = proc.sdma_usage + cuOccupancy = proc.cu_occupancy else: - logging.debug('Unable to fetch PID VRAM information') - dataArray.append([pid, getName(pid), str(gpuNumber), str(vramUsage), str(sdmaUsage)]) + logging.debug('Unable to fetch process info by PID') + dataArray.append([pid, getName(pid), str(gpuNumber), str(vramUsage), str(sdmaUsage), str(cuOccupancy)]) printLog(None, 'KFD process information:', None) print2DArray(dataArray) printLogSpacer()