From fd751ba918a8580f8d080bcb25bc93f913e0fd08 Mon Sep 17 00:00:00 2001 From: gabrpham_amdeng Date: Tue, 17 Jun 2025 19:59:34 -0500 Subject: [PATCH] Changed NUM_CU to CU % --- CHANGELOG.md | 18 +++++++++--------- amdsmi_cli/amdsmi_commands.py | 6 +++++- amdsmi_cli/amdsmi_logger.py | 11 +++++++---- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3ca787184..6dfce72a9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,16 +45,16 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr +-------------------------------------+----------------------------------------+ +------------------------------------------------------------------------------+ | Processes: | -| GPU PID Process Name GTT_MEM VRAM_MEM MEM_USAGE NUM_CU | +| GPU PID Process Name GTT_MEM VRAM_MEM MEM_USAGE CU % | |==============================================================================| -| 0 1253994 rvs 2.0 MB 2.4 GB 4.6 GB 0 | -| 1 1253994 rvs 2.0 MB 2.4 GB 4.6 GB 0 | -| 2 1253994 rvs 2.0 MB 2.5 GB 4.6 GB 0 | -| 3 1253994 rvs 2.0 MB 2.5 GB 4.6 GB 0 | -| 4 1253994 rvs 2.0 MB 2.4 GB 4.6 GB 114 | -| 5 1253994 rvs 2.0 MB 2.4 GB 4.6 GB 114 | -| 6 1253994 rvs 2.0 MB 2.4 GB 4.6 GB 114 | -| 7 1253994 rvs 2.0 MB 2.4 GB 4.6 GB 0 | +| 0 2427396 rvs 2.0 MB 2.0 GB 2.5 GB 0.0 % | +| 1 2427396 rvs 2.0 MB 2.2 GB 2.6 GB 0.0 % | +| 2 2427396 rvs 2.0 MB 2.3 GB 2.7 GB 0.0 % | +| 3 2427396 rvs 2.0 MB 2.3 GB 2.7 GB 0.0 % | +| 4 2427396 rvs 2.0 MB 2.1 GB 2.5 GB 0.0 % | +| 5 2427396 rvs 2.0 MB 2.0 GB 2.2 GB 0.0 % | +| 6 2427396 rvs 2.0 MB 2.1 GB 2.4 GB 0.0 % | +| 7 2427396 rvs 2.0 MB 2.1 GB 2.5 GB 0.0 % | +------------------------------------------------------------------------------+ ``` diff --git a/amdsmi_cli/amdsmi_commands.py b/amdsmi_cli/amdsmi_commands.py index f3896bb388..218c30c9ad 100644 --- a/amdsmi_cli/amdsmi_commands.py +++ b/amdsmi_cli/amdsmi_commands.py @@ -6601,9 +6601,12 @@ class AMDSMICommands(): asic_info = amdsmi_interface.amdsmi_get_gpu_asic_info(processor) market_name = asic_info['market_name'] oam_id = asic_info['oam_id'] + # get num_cu now for use later + max_cu = float(asic_info['num_compute_units']) except amdsmi_exception.AmdSmiLibraryException as e: market_name = "N/A" oam_id = "N/A" + max_cu = "N/A" gpu_info_dict.update({"market_name": market_name}) gpu_info_dict.update({"oam_id": oam_id}) @@ -6701,7 +6704,8 @@ class AMDSMICommands(): proc_info_dict['gtt'] = self.helpers.convert_bytes_to_readable(proc['memory_usage']['gtt_mem']) proc_info_dict['vram'] = self.helpers.convert_bytes_to_readable(proc['memory_usage']['vram_mem']) proc_info_dict['mem_usage'] = self.helpers.convert_bytes_to_readable(proc['mem']) - proc_info_dict['cu_occupancy'] = str(proc['cu_occupancy']) + num_cu = float(proc['cu_occupancy']) + proc_info_dict['cu_occupancy'] = {"current_cu": num_cu, "max_cu": max_cu} all_process_list.append(proc_info_dict) except amdsmi_exception.AmdSmiLibraryException as e: logging.debug("Failed to get process list for gpu %s | %s", gpu_id, e.get_error_info()) diff --git a/amdsmi_cli/amdsmi_logger.py b/amdsmi_cli/amdsmi_logger.py index fdf4f8d85c..d9b1622051 100644 --- a/amdsmi_cli/amdsmi_logger.py +++ b/amdsmi_cli/amdsmi_logger.py @@ -1072,18 +1072,21 @@ class AMDSMILogger(): # print process list of all GPUs last print(default_line_1) print("| Processes: |") - print("| GPU PID Process Name GTT_MEM VRAM_MEM MEM_USAGE NUM_CU |") + print("| GPU PID Process Name GTT_MEM VRAM_MEM MEM_USAGE CU % |") print(default_line_5) if len(output['processes']) != 0: for process in output['processes']: gpu_id = str(process['gpu']).rjust(4) pid = str(process['pid']).rjust(9) - process_name = str(process['name']).ljust(20) + process_name = str(process['name']).ljust(19) gtt_mem = str(process['gtt']).rjust(8) vram_mem = str(process['vram']).rjust(8) mem_usage = str(process['mem_usage']).rjust(9) - cu_occupancy = str(process['cu_occupancy']).rjust(6) - print("| {0:4s} {1:9s} {2:20s} {3:8s} {4:8s} {5:9s} {6:6s} |".format( + if process['cu_occupancy']['max_cu'] != "N/A": + cu_occupancy = (str(round(process['cu_occupancy']['current_cu'] / process['cu_occupancy']['max_cu'] * 100, 1)) + " %").rjust(7) + else: + cu_occupancy = "N/A" + print("| {0:4.4s} {1:9.9s} {2:19.19s} {3:8.8s} {4:8.8s} {5:9.9s} {6:7.7s} |".format( gpu_id, pid, process_name, gtt_mem, vram_mem, mem_usage, cu_occupancy)) else: print("| No running processes found |")