From 42f11bdd63368d26fa4910a5804073fd7c71a608 Mon Sep 17 00:00:00 2001 From: "Bill(Shuzhou) Liu" Date: Thu, 9 Jun 2022 08:59:22 -0400 Subject: [PATCH 1/5] Remove python pyc file when uninstall rpm Remove python pyc file when uninstall rpm. Change-Id: I6520b51aac34060b5b90f94a016cec1827a4973f --- RPM/postun.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RPM/postun.in b/RPM/postun.in index d54cd9b2ea..bb93d0fb73 100755 --- a/RPM/postun.in +++ b/RPM/postun.in @@ -4,3 +4,6 @@ if [ $1 -le 1 ] && [ "@ENABLE_LDCONFIG@" == "ON" ]; then rm -f /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf ldconfig fi + +# remove pyc file generated by python +rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/libexec/rocm_smi/__pycache__ From 2b8d0ad70ff698853e3974a15a3a99b527a3b732 Mon Sep 17 00:00:00 2001 From: Ori Messinger Date: Tue, 31 May 2022 06:13:56 -0400 Subject: [PATCH 2/5] ROCm SMI CLI: Fix setClockRange Error This patch changes the error handling for setClockRange. When a device does not support modifying a clock type (sclk/mclk), an error message is printed through the python CLI. Signed-off-by: Ori Messinger Change-Id: I37d9ea4189b1ca81e5deaab5efa6cfa4901b89b3 --- python_smi_tools/rocm_smi.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python_smi_tools/rocm_smi.py b/python_smi_tools/rocm_smi.py index 04dc643019..309bec4ecc 100755 --- a/python_smi_tools/rocm_smi.py +++ b/python_smi_tools/rocm_smi.py @@ -772,11 +772,13 @@ def setClockRange(deviceList, clkType, minvalue, maxvalue, autoRespond): printLogSpacer(' Set Valid %s Range ' % (clkType)) for device in deviceList: ret = rocmsmi.rsmi_dev_clk_range_set(device, int(minvalue), int(maxvalue), rsmi_clk_names_dict[clkType]) - if rsmi_ret_ok(ret, device): + if rsmi_ret_ok(ret, device, silent=True): printLog(device, 'Successfully set %s from %s(MHz) to %s(MHz)' % (clkType, minvalue, maxvalue), None) else: printErrLog(device, 'Unable to set %s from %s(MHz) to %s(MHz)' % (clkType, minvalue, maxvalue)) RETCODE = 1 + if ret == rsmi_status_t.RSMI_STATUS_NOT_SUPPORTED: + printLog(device, 'Setting %s range is not supported for this device.' % (clkType), None) def setVoltageCurve(deviceList, point, clk, volt, autoRespond): From b72c464ac098a0124f69e21d4d1aadf7ed0cbb42 Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Fri, 3 Jun 2022 12:03:27 -0700 Subject: [PATCH 3/5] SWDEV-321112 - Use GNUInstallDirs Use GNUInstallDirs variables to determine the location of LIBDIR, BINDIR, INCLUDEDIR, DOCDIR Note that CMAKE_INSTALL_LIBDIR is overriden, since the default for RHEL is lib64, but ROCm packaging wants it to be lib always. Distros or users can easily override this. Change-Id: I616152ccd2bc1f5a60bffa940312b38ca6e88c04 --- CMakeLists.txt | 21 +++++++++++---------- DEBIAN/postinst.in | 2 +- DEBIAN/prerm.in | 2 +- RPM/post.in | 2 +- RPM/postun.in | 2 +- oam/CMakeLists.txt | 6 +++--- rocm_smi-backward-compat.cmake | 8 ++++---- rocm_smi/CMakeLists.txt | 22 +++++++++++----------- 8 files changed, 33 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 561a035b35..c9ed159b6b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,9 @@ set(ROCM_SMI_PACKAGE rocm-smi-lib) project(${AMD_SMI_LIBS_TARGET}) set(COMMON_PROJ_ROOT ${PROJECT_SOURCE_DIR}) +# Set default libdir to be "lib" for ROCm, distros/users can override this +set(CMAKE_INSTALL_LIBDIR "lib" CACHE STRING "Library install directory") +include(GNUInstallDirs) ## Verbose output. set(CMAKE_VERBOSE_MAKEFILE on) @@ -149,19 +152,17 @@ option(FILE_REORG_BACKWARD_COMPATIBILITY "Enable File Reorg with backward compat if(FILE_REORG_BACKWARD_COMPATIBILITY) include(rocm_smi-backward-compat.cmake) endif() -#TODO: Should use GNUInstallDirs to match distro standards -#This need fix in subdirectory CMakefile as well -#include(GNUInstallDirs) -set(LIB_INSTALL_DIR "lib") -set(INCLUDE_INSTALL_DIR "include") -set(BIN_INSTALL_DIR "bin") + +set(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}") +set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}") +set(BIN_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}") include(CMakePackageConfigHelpers) configure_package_config_file( rocm_smi-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/rocm_smi-config.cmake - INSTALL_DESTINATION ${LIB_INSTALL_DIR}/cmake/rocm_smi + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/rocm_smi PATH_VARS LIB_INSTALL_DIR INCLUDE_INSTALL_DIR BIN_INSTALL_DIR ) @@ -175,7 +176,7 @@ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocm_smi-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/rocm_smi-config-version.cmake DESTINATION - lib/cmake/${ROCM_SMI} + ${CMAKE_INSTALL_LIBDIR}/cmake/${ROCM_SMI} COMPONENT dev ) @@ -190,11 +191,11 @@ export(PACKAGE rocm_smi) # Create the rocm_smiConfig.cmake and rocm_smiConfigVersion files # ... for the build tree install(EXPORT rocm_smiTargets DESTINATION - "lib/cmake/${ROCM_SMI}" COMPONENT dev) + "${CMAKE_INSTALL_LIBDIR}/cmake/${ROCM_SMI}" COMPONENT dev) #License file set(CPACK_RPM_PACKAGE_LICENSE "NCSA") -install( FILES ${CPACK_RESOURCE_FILE_LICENSE} DESTINATION share/doc/${ROCM_SMI} RENAME LICENSE.txt) +install( FILES ${CPACK_RESOURCE_FILE_LICENSE} DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/${ROCM_SMI} RENAME LICENSE.txt) ########################### # Packaging directives diff --git a/DEBIAN/postinst.in b/DEBIAN/postinst.in index 5fda052286..d916aa7b85 100755 --- a/DEBIAN/postinst.in +++ b/DEBIAN/postinst.in @@ -5,7 +5,7 @@ set -e do_ldconfig() { # left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build if [ "@ENABLE_LDCONFIG@" == "ON" ]; then - echo @CPACK_PACKAGING_INSTALL_PREFIX@/lib > /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf + echo @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ > /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf ldconfig fi } diff --git a/DEBIAN/prerm.in b/DEBIAN/prerm.in index 65ec3de3ad..bc9cc2ef33 100755 --- a/DEBIAN/prerm.in +++ b/DEBIAN/prerm.in @@ -12,7 +12,7 @@ rm_ldconfig() { rm_pyc() { # remove pyc file generated by python - rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/libexec/rocm_smi/__pycache__ + rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/rocm_smi/__pycache__ } case "$1" in diff --git a/RPM/post.in b/RPM/post.in index df1074537a..a7f518b81d 100755 --- a/RPM/post.in +++ b/RPM/post.in @@ -1,5 +1,5 @@ # left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build if [ "@ENABLE_LDCONFIG@" == "ON" ]; then - echo -e "@CPACK_PACKAGING_INSTALL_PREFIX@/lib\n@CPACK_PACKAGING_INSTALL_PREFIX@/lib64" > /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf + echo -e "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@" > /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf ldconfig fi diff --git a/RPM/postun.in b/RPM/postun.in index bb93d0fb73..72f4c565e2 100755 --- a/RPM/postun.in +++ b/RPM/postun.in @@ -6,4 +6,4 @@ if [ $1 -le 1 ] && [ "@ENABLE_LDCONFIG@" == "ON" ]; then fi # remove pyc file generated by python -rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/libexec/rocm_smi/__pycache__ +rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/rocm_smi/__pycache__ diff --git a/oam/CMakeLists.txt b/oam/CMakeLists.txt index 8cbf9dd918..7e96c85a49 100644 --- a/oam/CMakeLists.txt +++ b/oam/CMakeLists.txt @@ -101,12 +101,12 @@ target_include_directories(${OAM_TARGET} ## Add the install directives for the runtime library. install(TARGETS ${OAM_TARGET} EXPORT rocm_smiTargets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${OAM_COMPONENT}) install(FILES ${COMMON_SRC_ROOT}/oam/include/oam/oam_mapi.h ${COMMON_SRC_ROOT}/oam/include/oam/amd_oam.h - DESTINATION include/oam) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/oam) # Generate Doxygen documentation if (DOXYGEN_FOUND) diff --git a/rocm_smi-backward-compat.cmake b/rocm_smi-backward-compat.cmake index 8d31ebf087..aa8fd9c49e 100644 --- a/rocm_smi-backward-compat.cmake +++ b/rocm_smi-backward-compat.cmake @@ -72,7 +72,7 @@ function(generate_wrapper_header) set(include_guard "${include_guard}COMGR_WRAPPER_INCLUDE_${INC_GAURD_NAME}_H") #set #include statement get_filename_component(file_name ${header_file} NAME) - set(include_statements "${include_statements}#include \"../../../include/${ROCM_SMI}/${file_name}\"\n") + set(include_statements "${include_statements}#include \"../../../${CMAKE_INSTALL_INCLUDEDIR}/${ROCM_SMI}/${file_name}\"\n") configure_file(${RSMI_WRAPPER_DIR}/header.hpp.in ${RSMI_WRAPPER_INC_DIR}/${file_name}) unset(include_guard) unset(include_statements) @@ -90,7 +90,7 @@ function(generate_wrapper_header) set(include_guard "${include_guard}COMGR_WRAPPER_INCLUDE_${INC_GAURD_NAME}_H") #set #include statement get_filename_component(file_name ${header_file} NAME) - set(include_statements "${include_statements}#include \"../../../include/${OAM_TARGET_NAME}/${file_name}\"\n") + set(include_statements "${include_statements}#include \"../../../${CMAKE_INSTALL_INCLUDEDIR}/${OAM_TARGET_NAME}/${file_name}\"\n") configure_file(${RSMI_WRAPPER_DIR}/header.hpp.in ${OAM_WRAPPER_INC_DIR}/${file_name}) unset(include_guard) unset(include_statements) @@ -127,7 +127,7 @@ function(create_library_symlink) add_custom_target(link_${file_name} ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink - ../../lib/${file_name} ${RSMI_WRAPPER_LIB_DIR}/${file_name}) + ../../${CMAKE_INSTALL_LIBDIR}/${file_name} ${RSMI_WRAPPER_LIB_DIR}/${file_name}) endforeach() file(MAKE_DIRECTORY ${OAM_WRAPPER_LIB_DIR}) @@ -155,7 +155,7 @@ function(create_library_symlink) add_custom_target(link_${file_name} ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink - ../../lib/${file_name} ${OAM_WRAPPER_LIB_DIR}/${file_name}) + ../../${CMAKE_INSTALL_LIBDIR}/${file_name} ${OAM_WRAPPER_LIB_DIR}/${file_name}) endforeach() endfunction() diff --git a/rocm_smi/CMakeLists.txt b/rocm_smi/CMakeLists.txt index 862199d3e3..c594eeb8af 100755 --- a/rocm_smi/CMakeLists.txt +++ b/rocm_smi/CMakeLists.txt @@ -108,29 +108,29 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) add_custom_target(link-rocm-smi ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink - ../libexec/${ROCM_SMI}/rocm_smi.py ${CMAKE_CURRENT_BINARY_DIR}/bin/rocm-smi) + ../${CMAKE_INSTALL_LIBEXECDIR}/${ROCM_SMI}/rocm_smi.py ${CMAKE_CURRENT_BINARY_DIR}/bin/rocm-smi) ## Add the install directives for the runtime library. install(TARGETS ${ROCM_SMI_TARGET} EXPORT rocm_smiTargets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${ROCM_SMI_COMPONENT}) install(FILES ${COMMON_SRC_ROOT}/include/rocm_smi/rocm_smi.h - DESTINATION include/rocm_smi) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm_smi) install(FILES ${COMMON_SRC_ROOT}/include/rocm_smi/${ROCM_SMI_TARGET}Config.h - DESTINATION include/rocm_smi) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm_smi) install(FILES ${COMMON_SRC_ROOT}/include/rocm_smi/kfd_ioctl.h - DESTINATION include/rocm_smi) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm_smi) install(FILES ${COMMON_SRC_ROOT}/python_smi_tools/rsmiBindings.py - DESTINATION libexec/${ROCM_SMI}) + DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/${ROCM_SMI}) install(FILES ${COMMON_SRC_ROOT}/python_smi_tools/rocm_smi.py PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE - DESTINATION libexec/${ROCM_SMI}) + DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/${ROCM_SMI}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bin/rocm-smi - DESTINATION bin) + DESTINATION ${CMAKE_INSTALL_BINDIR}) # Generate Doxygen documentation find_package(Doxygen) @@ -157,9 +157,9 @@ if (DOXYGEN_FOUND AND LATEX_FOUND) add_dependencies(${ROCM_SMI_TARGET} docs) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/latex/refman.pdf - DESTINATION share/doc/${ROCM_SMI} RENAME ${RSMI_MANUAL_NAME}.pdf) + DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/${ROCM_SMI} RENAME ${RSMI_MANUAL_NAME}.pdf) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../README.md - DESTINATION share/doc/${ROCM_SMI}/) + DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/${ROCM_SMI}/) else() message("Doxygen or Latex is not found. Will not generate documents.") endif(DOXYGEN_FOUND AND LATEX_FOUND) From 4dd2398f3db26b900d3b605495afac7540a1b3ac Mon Sep 17 00:00:00 2001 From: Elena Sakhnovitch Date: Thu, 19 May 2022 16:58:48 -0400 Subject: [PATCH 4/5] [rocm_smi.py] error feedback improvement Cleaning overally verbose error reporting system. Signed-off-by: Elena Sakhnovitch Signed-off-by: Sreekant Somasekharan Change-Id: Icc96086810b8dcfc426848b8c349a2572026c3bd --- python_smi_tools/rocm_smi.py | 19 +++++++------------ python_smi_tools/rsmiBindings.py | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/python_smi_tools/rocm_smi.py b/python_smi_tools/rocm_smi.py index 309bec4ecc..a1eb198e09 100755 --- a/python_smi_tools/rocm_smi.py +++ b/python_smi_tools/rocm_smi.py @@ -509,7 +509,6 @@ def printLog(device, metricName, value): logstr = 'GPU[%s]\t\t: %s' % (device, metricName) if device is None: logstr = logstr[13:] - logging.debug(logstr) # Force thread safe printing print(logstr + '\n', end='') @@ -2026,7 +2025,7 @@ def showProfile(deviceList): status = rsmi_power_profile_status_t() for device in deviceList: ret = rocmsmi.rsmi_dev_power_profile_presets_get(device, 0, byref(status)) - if rsmi_ret_ok(ret, device, 'profiles'): + if rsmi_ret_ok(ret, device, 'profiles', silent=False): binaryMaskString = str(format(status.available_profiles, '07b'))[::-1] bitMaskPosition = 0 profileNumber = 0 @@ -2058,7 +2057,7 @@ def showRange(deviceList, rangeType): odvf = rsmi_od_volt_freq_data_t() for device in deviceList: ret = rocmsmi.rsmi_dev_od_volt_info_get(device, byref(odvf)) - if rsmi_ret_ok(ret, device, 'od volt'): + if rsmi_ret_ok(ret, device, 'od volt', silent=False): if rangeType == 'sclk': printLog(device, 'Valid sclk range: %sMhz - %sMhz' % ( int(odvf.curr_sclk_range.lower_bound / 1000000), int(odvf.curr_sclk_range.upper_bound / 1000000)), None) @@ -2080,8 +2079,6 @@ def showRange(deviceList, rangeType): None) else: printLog(device, 'Unable to display %s range' % (rangeType), None) - else: - printLog(device, 'Unable to display %s range' % (rangeType), None) printLogSpacer() @@ -2294,13 +2291,11 @@ def showVoltageCurve(deviceList): odvf = rsmi_od_volt_freq_data_t() for device in deviceList: ret = rocmsmi.rsmi_dev_od_volt_info_get(device, byref(odvf)) - if rsmi_ret_ok(ret, device, 'od volt'): + if rsmi_ret_ok(ret, device, 'od volt', silent=False): for position in range(3): printLog(device, 'Voltage point %d: %sMhz %smV' % ( position, int(list(odvf.curve.vc_points)[position].frequency / 1000000), int(list(odvf.curve.vc_points)[position].voltage)), None) - else: - printLog(device, 'Voltage Curve is not supported', None) printLogSpacer() @@ -2790,10 +2785,10 @@ def rsmi_ret_ok(my_ret, device=None, metric=None, silent=False): returnString += ' %s: ' % (metric) returnString += '%s\t' % (err_str.value.decode()) if not PRINT_JSON: - if silent: - logging.info('%s', returnString) - else: - logging.error('%s', returnString) + logging.debug('%s', returnString) + if not silent: + if my_ret in rsmi_status_verbose_err_out: + printLog(device, rsmi_status_verbose_err_out[my_ret], None) RETCODE = my_ret return False return True diff --git a/python_smi_tools/rsmiBindings.py b/python_smi_tools/rsmiBindings.py index 090b85c3d8..7da7c2bc8c 100644 --- a/python_smi_tools/rsmiBindings.py +++ b/python_smi_tools/rsmiBindings.py @@ -69,6 +69,27 @@ class rsmi_status_t(c_int): RSMI_STATUS_UNKNOWN_ERROR = 0xFFFFFFFF +#Dictionary of rsmi ret codes and it's verbose output +rsmi_status_verbose_err_out = { + rsmi_status_t.RSMI_STATUS_SUCCESS: 'Operation was successful', + rsmi_status_t.RSMI_STATUS_INVALID_ARGS: 'Invalid arguments provided', + rsmi_status_t.RSMI_STATUS_NOT_SUPPORTED: 'Not supported on the given system', + rsmi_status_t.RSMI_STATUS_FILE_ERROR: 'Problem accessing a file', + rsmi_status_t.RSMI_STATUS_PERMISSION: 'Permission denied', + rsmi_status_t.RSMI_STATUS_OUT_OF_RESOURCES: 'Unable to acquire memory or other resource', + rsmi_status_t.RSMI_STATUS_INTERNAL_EXCEPTION: 'An internal exception was caught', + rsmi_status_t.RSMI_STATUS_INPUT_OUT_OF_BOUNDS: 'Provided input is out of allowable or safe range', + rsmi_status_t.RSMI_INITIALIZATION_ERROR: 'Error occured during rsmi initialization', + rsmi_status_t.RSMI_STATUS_NOT_YET_IMPLEMENTED: 'Requested function is not implemented on this setup', + rsmi_status_t.RSMI_STATUS_NOT_FOUND: 'Item searched for but not found', + rsmi_status_t.RSMI_STATUS_INSUFFICIENT_SIZE: 'Insufficient resources available', + rsmi_status_t.RSMI_STATUS_INTERRUPT: 'Interrupt occured during execution', + rsmi_status_t.RSMI_STATUS_UNEXPECTED_SIZE: 'Unexpected amount of data read', + rsmi_status_t.RSMI_STATUS_NO_DATA: 'No data found for the given input', + rsmi_status_t.RSMI_STATUS_UNKNOWN_ERROR: 'Unknown error occured' +} + + class rsmi_init_flags_t(c_int): RSMI_INIT_FLAG_ALL_GPUS = 0x1 From 6b6e8403378ae84ba8ee5d7f17f64ed7663332b5 Mon Sep 17 00:00:00 2001 From: Kent Russell Date: Thu, 16 Jun 2022 10:58:00 -0400 Subject: [PATCH 5/5] rocm_smi.py: Handle corrupted serial number If the FRU has been corrupted, then the serial number will come in with any manner of random bytes, which will cause decode() to fail spectacularily. Check that the serial returned by the kernel is alphanumeric, and print to the error log if not (then continue to the next device). Change-Id: If4f35b140b6089e02729b1490ed6b48d614a122a --- python_smi_tools/rocm_smi.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python_smi_tools/rocm_smi.py b/python_smi_tools/rocm_smi.py index a1eb198e09..de014a77f3 100755 --- a/python_smi_tools/rocm_smi.py +++ b/python_smi_tools/rocm_smi.py @@ -2161,6 +2161,10 @@ def showSerialNumber(deviceList): for device in deviceList: sn = create_string_buffer(256) ret = rocmsmi.rsmi_dev_serial_number_get(device, sn, 256) + if not str(sn).isalnum(): + printErrLog(device, "FRU Serial Number contains non-alphanumeric characters. FRU is likely corrupted") + continue + if rsmi_ret_ok(ret, device) and sn.value.decode(): printLog(device, 'Serial Number', sn.value.decode()) else: