Skip to content

Commit 2131287

Browse files
authored
Merge amd-staging into amd-mainline 20250819 (#634)
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com> Signed-off-by: Zoy Bai <Zoy.Bai@amd.com>
2 parents a8ccdff + e8fa06d commit 2131287

29 files changed

Lines changed: 1307 additions & 544 deletions

‎CHANGELOG.md‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr
1919

2020
### Resolved Issues
2121

22+
- Fixed `amd-smi monitor` errors on guest systems
23+
```shell
24+
$ amd-smi monitor
25+
AttributeError: 'Namespace' object has no attribute 'violation'
26+
```
27+
28+
Now properly shows:
29+
```shell
30+
$ amd-smi monitor
31+
GPU XCP POWER GPU_T MEM_T GFX_CLK GFX% MEM% ENC% DEC% VRAM_USAGE
32+
0 0 12 W 40 °C 44 °C 9 MHz 8 % 1 % N/A 0 % 0.2/ 25.4 GB
33+
```
34+
2235
### Upcoming Changes
2336

2437
- N/A
@@ -179,6 +192,11 @@ $ amd-smi
179192
- **Updated `amdsmi_bdf_t` in `amdsmi.h`**.
180193
- The `amdsmi_bdf_t` union was changed to have an identical unnamed struct for backwards compatiblity
181194

195+
- **Updated `amdsmi_get_temp_metric` and `amdsmi_temperature_type_t` with new values**.
196+
- New values have added to `amdsmi_temperature_type_t` representing various baseboard and gpuboard temperature measures.
197+
- `amdsmi_get_temp_metric` API has also been updated to be able to take in and return the respective values for the new
198+
temperature types.
199+
182200
### Removed
183201

184202
- **Removed unnecessary API, `amdsmi_free_name_value_pairs(),` from amdsmi.h**
@@ -358,7 +376,9 @@ $ amd-smi
358376

359377
### Upcoming changes
360378

361-
- N/A
379+
- **`amd-smi metric` will also display gpuboard and baseboard temperatures**.
380+
- This change is meant to follow the API change to amdsmi_get_temp_metric. If these measures are not available due
381+
to hardware incompatibility, then they will simply not be displayed in the results when using the metric command.
362382

363383
### Known issues
364384

@@ -625,7 +645,11 @@ $ amd-smi
625645

626646
### Known issues
627647

628-
- N/A
648+
- `amd-smi monitor` does not work on guest systems
649+
```shell
650+
$ amd-smi monitor
651+
AttributeError: 'Namespace' object has no attribute 'violation'
652+
```
629653

630654
## amd_smi_lib for ROCm 6.4.0
631655

‎CMakeLists.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ option(ENABLE_ASAN_PACKAGING "" OFF)
9797
option(ENABLE_ESMI_LIB "Build ESMI Library" ON)
9898
option(BUILD_EXAMPLES "Build examples" OFF)
9999

100+
# If amdsmi is built as a static library, it should support being embedded in other programs. The setting below essentially enables the -fPIC flag.
101+
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Enable position independent code for all targets")
102+
mark_as_advanced(CMAKE_POSITION_INDEPENDENT_CODE)
103+
100104
include(CMakeDependentOption)
101105
# these options don't work without BUILD_SHARED_LIBS
102106
cmake_dependent_option(BUILD_WRAPPER "Rebuild AMDSMI-wrapper" OFF "BUILD_SHARED_LIBS" OFF)

‎amdsmi_cli/amdsmi_commands.py‎

Lines changed: 213 additions & 174 deletions
Large diffs are not rendered by default.

‎amdsmi_cli/amdsmi_helpers.py‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ def get_accelerator_partition_profile_config(self):
760760
return accelerator_partition_profiles
761761
break
762762
except Exception as e:
763-
logging.debug(f"AMDSMIHelpers.get_accelerator_partition_profile_config - Unexpected error occured --> Unable to get accelerator partition profile config for device {dev}: {str(e)}")
763+
logging.debug(f"AMDSMIHelpers.get_accelerator_partition_profile_config - Unexpected error occurred --> Unable to get accelerator partition profile config for device {dev}: {str(e)}")
764764
break
765765
return accelerator_partition_profiles
766766

@@ -822,6 +822,13 @@ def get_power_caps(self):
822822
except amdsmi_interface.AmdSmiLibraryException as e:
823823
logging.debug(f"AMDSMIHelpers.get_power_caps - Unable to get power cap info for device {dev}: {str(e)}")
824824
continue
825+
826+
# If we never found a real min or max, set them to N/A
827+
if power_cap_min == amdsmi_interface.MaxUIntegerTypes.UINT64_T:
828+
power_cap_min = "N/A"
829+
if power_cap_max == 0:
830+
power_cap_max = "N/A"
831+
825832
return (power_cap_min, power_cap_max)
826833

827834

@@ -1177,7 +1184,7 @@ def display_cper_files_generated(self, entries, device_handle, folder):
11771184
if not getattr(self, "_cper_display_initialized", False):
11781185
# Warning if no folder was specified elsewhere
11791186
if not getattr(self, "_cper_warning_printed", False):
1180-
print(f"WARNING:No cper files will be dumped unless --folder=<folder_name> is specified.")
1187+
print(f"WARNING:No cper files will be dumped unless --folder=<folder_name> is specified and cper entries exist.")
11811188
self._cper_warning_printed = True
11821189

11831190
self._print_header(folder)
@@ -1441,11 +1448,13 @@ def ras_cper(self, args, device_handle, logger, gpu_idx):
14411448
logger.set_cper_exit_message(False)
14421449
self.stop = False
14431450

1451+
num_entries = 0
14441452
while True:
14451453
try:
14461454
entries, new_cursor, cper_data, status_code = amdsmi_interface.amdsmi_get_gpu_cper_entries(
14471455
device_handle, severity_mask, buffer_size, args.cursor[gpu_idx])
14481456
logging.debug(f"cper_entries | entries: {entries}")
1457+
num_entries = num_entries + len(entries)
14491458
except amdsmi_exception.AmdSmiLibraryException as e:
14501459
if e.get_error_code() == amdsmi_interface.amdsmi_wrapper.AMDSMI_STATUS_NO_PERM:
14511460
raise PermissionError('Error opening CPER file. This command requires elevation') from e
@@ -1462,7 +1471,11 @@ def ras_cper(self, args, device_handle, logger, gpu_idx):
14621471
break
14631472
if args.folder:
14641473
self.dump_cper_entries(args.folder, entries, cper_data, device_handle, args.file_limit)
1465-
break
1474+
else:
1475+
self.display_cper_files_generated(entries, device_handle, args.folder)
1476+
if num_entries == 0 and not args.follow:
1477+
if args.folder:
1478+
self.dump_cper_entries(args.folder, entries, cper_data, device_handle, args.file_limit)
14661479
else:
14671480
self.display_cper_files_generated(entries, device_handle, args.folder)
14681481

‎amdsmi_cli/amdsmi_logger.py‎

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
import time
2626
from typing import Dict
2727
from enum import Enum
28-
import inspect
2928
from amdsmi_helpers import AMDSMIHelpers
30-
import amdsmi_cli_exceptions
3129

3230
class AMDSMILogger():
3331
def __init__(self, format='human_readable', destination='stdout', helpers=None) -> None:
@@ -92,10 +90,10 @@ def clear_multiple_devices_output(self):
9290
self.multiple_device_output.clear()
9391

9492

95-
def cper_exit_message(self):
96-
""" Store the cper exit message
93+
def get_cper_exit_message(self):
94+
""" Get the cper exit message
9795
params:
98-
message (str) - message to store
96+
None
9997
return:
10098
cper_exit_message (bool) - True if cper exit message is set
10199
"""
@@ -239,9 +237,10 @@ def _convert_json_to_tabular(self, json_object: Dict[str, any], dynamic=False):
239237
string_process_value = str(process_value)
240238
if process_key == "name":
241239
# Truncate name if too long
242-
process_name = string_process_value.split('/')[-1][:17]
243-
if process_name == "":
240+
if string_process_value == "" or string_process_value == "N/A":
244241
process_name = "N/A"
242+
else:
243+
process_name = string_process_value.split('/')[-1][:17]
245244
table_values += process_name.rjust(17)
246245
elif process_key == "pid":
247246
table_values += string_process_value.rjust(9)
@@ -459,7 +458,7 @@ def _store_core_output_amdsmi(self, core_id, argument, data):
459458
else:
460459
self.output[argument] = data
461460
else:
462-
raise amdsmi_cli_exceptions(self, "Invalid output format given, only json, csv, and human_readable supported")
461+
raise ValueError("Invalid output format: expected json, csv, or human_readable")
463462

464463

465464
def _store_cpu_output_amdsmi(self, cpu_id, argument, data):
@@ -481,7 +480,7 @@ def _store_cpu_output_amdsmi(self, cpu_id, argument, data):
481480
else:
482481
self.output[argument] = data
483482
else:
484-
raise amdsmi_cli_exceptions(self, "Invalid output format given, only json, csv, and human_readable supported")
483+
raise ValueError("Invalid output format: expected json, csv, or human_readable")
485484

486485

487486
def _store_output_amdsmi(self, gpu_id, argument, data):
@@ -503,7 +502,7 @@ def _store_output_amdsmi(self, gpu_id, argument, data):
503502
else:
504503
self.output[argument] = data
505504
else:
506-
raise amdsmi_cli_exceptions(self, "Invalid output format given, only json, csv, and human_readable supported")
505+
raise ValueError("Invalid output format: expected json, csv, or human_readable")
507506

508507

509508
def store_multiple_device_output(self):
@@ -1024,11 +1023,24 @@ def print_default_output(self, output: Dict):
10241023
amdgpu_version = "N/A".ljust(8)
10251024
else:
10261025
amdgpu_version = str(driver_version['driver_version'])[:8].ljust(8)
1026+
fw_pldm_version = str(output['version_info']['fw pldm version'])
1027+
vbios_version = str(output['version_info']['vbios version'])
10271028

10281029
# print GPU info
10291030
print(default_line_1)
10301031
print("| AMD-SMI {0:20s} amdgpu version: {1:8s} ROCm version: {2:8s} |".format(amd_smi_version.ljust(20), amdgpu_version, rocm_version))
1031-
print("| Platform: {0:20.20s} {1:46s}|".format(str(self.helpers.os_info()), ""))
1032+
1033+
# adjust format depending on whether vbios or fw pldm version is present
1034+
if vbios_version != "N/A" and fw_pldm_version != "N/A":
1035+
print("| VBIOS version: {0:22s} {1:12s} FW PLDM: {2:15s}|".format(vbios_version, "", fw_pldm_version))
1036+
elif vbios_version != "N/A" and fw_pldm_version == "N/A":
1037+
print("| VBIOS version: {0:22s} {1:37s} |".format(vbios_version, ""))
1038+
elif fw_pldm_version != "N/A" and vbios_version == "N/A":
1039+
print("| FW PLDM: {0:15s} {1:50s} |".format(fw_pldm_version, ""))
1040+
else:
1041+
pass # Both VBIOS and FW PLDM versions are "N/A" so skip this line
1042+
1043+
print("| Platform: {0:25.25s} {1:41s}|".format(str(self.helpers.os_info()), ""))
10321044
print(default_line_2)
10331045
print("| BDF GPU-Name | Mem-Uti Temp UEC Power-Usage |")
10341046
print("| GPU HIP-ID OAM-ID Partition-Mode | GFX-Uti Fan Mem-Usage |")

0 commit comments

Comments
 (0)