From c9201f7736a10020e7b6052ea7f5cb0e991c51c2 Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Wed, 24 Jul 2024 23:10:00 -0700 Subject: [PATCH 1/3] SWDEV-469004 - Append additonal path to system path rocm-smi is installed in /opt/rocm-ver/bin , but not as a soft link in wheel package For rocm-smi to work from bin directory, it need the extra path to find rsmiBindings.py Change-Id: I41388f680cb2ab9f11dc135639b0d30b66082392 --- python_smi_tools/rocm_smi.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/python_smi_tools/rocm_smi.py b/python_smi_tools/rocm_smi.py index e832ab1152..841355bf4a 100755 --- a/python_smi_tools/rocm_smi.py +++ b/python_smi_tools/rocm_smi.py @@ -24,7 +24,24 @@ import trace from io import StringIO from time import ctime from subprocess import check_output -from rsmiBindings import * +from typing import TYPE_CHECKING + +# only used for type checking +# pyright trips up and cannot find rsmiBindings without it +if TYPE_CHECKING: + from rsmiBindings import * + +try: + from rsmiBindings import * +except ImportError: + current_path = os.path.dirname(os.path.abspath(__file__)) + additional_path = f"{current_path}/../libexec/rocm_smi" + sys.path.append(additional_path) + try: + from rsmiBindings import * + except ImportError: + print(f"Still couldn't import 'rsmiBindings'. Make sure it's installed in {additional_path}") + sys.exit(1) # rocmSmiLib_cli version. Increment this as needed. # Major version - Increment when backwards-compatibility breaks @@ -196,7 +213,7 @@ def getBus(device, silent=False): # BDFID = ((DOMAIN & 0xFFFFFFFF) << 32) | ((PARTITION_ID & 0xF) << 28) | ((BUS & 0xFF) << 8) | # ((DEVICE & 0x1F) <<3 ) | (FUNCTION & 0x7) # bits [63:32] = domain - # bits [31:28] or bits [2:0] = partition id + # bits [31:28] or bits [2:0] = partition id # bits [27:16] = reserved # bits [15:8] = Bus # bits [7:3] = Device @@ -223,7 +240,7 @@ def getPartitionId(device, silent=False): # BDFID = ((DOMAIN & 0xFFFFFFFF) << 32) | ((PARTITION_ID & 0xF) << 28) | ((BUS & 0xFF) << 8) | # ((DEVICE & 0x1F) <<3 ) | (FUNCTION & 0x7) # bits [63:32] = domain - # bits [31:28] or bits [2:0] = partition id + # bits [31:28] or bits [2:0] = partition id # bits [27:16] = reserved # bits [15:8] = Bus # bits [7:3] = Device From 1b828b735ba98acccb95f907a416fbd86232d0fe Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Mon, 5 Aug 2024 09:49:19 -0700 Subject: [PATCH 2/3] SWDEV-476075 - Prevent the modification of interpreter directives CPACK is converting /usr/bin/env python3 to /usr/libexec/platform-python in RHEL8. Undefining __brp_mangle_shebangs will prevent the same Change-Id: Id285e2cea1de583853cec17eccf0a3a794cca643 --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b6b7c48d2..3ad742534e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -343,6 +343,9 @@ if(CPACK_RPM_PACKAGE_RELEASE) set(CPACK_RPM_PACKAGE_RELEASE_DIST ON) endif() +# Cpack converts !/usr/bin/env python3 to /usr/libexec/platform-python in RHEL8. +# prevent the BRP(buildroot policy) script from checking and modifying interpreter directives +set(CPACK_RPM_SPEC_MORE_DEFINE "%undefine __brp_mangle_shebangs") # The line below doesn't currently work; it may be this issue: # https://bugzilla.redhat.com/show_bug.cgi?id=1811358 From 055b023d2ec98ce01e3fa42f1c2c29b6735f220a Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Thu, 8 Aug 2024 01:40:55 -0500 Subject: [PATCH 3/3] Bump version tool:2.3.1+hash Signed-off-by: Maisam Arif Change-Id: Ic67456d7484c2f5a0ce0e086e56b29e20d9d9745 --- CHANGELOG.md | 5 +++-- python_smi_tools/rocm_smi.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d97cea7a4..d0c8d74dfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Full documentation for rocm_smi_lib is available at [https://rocm.docs.amd.com/] ***All information listed below is for reference and subject to change.*** -## rocm_smi_lib for ROCm 6.3 +## rocm_smi_lib for ROCm 6.2.1 ### Added @@ -16,7 +16,8 @@ Full documentation for rocm_smi_lib is available at [https://rocm.docs.amd.com/] ### Optimized -- N/A +- **Improved handling of UnicodeEncodeErrors with non UTF-8 locales** +Non UTF-8 locales were causing crashing on UTF-8 special characters ### Fixed diff --git a/python_smi_tools/rocm_smi.py b/python_smi_tools/rocm_smi.py index 841355bf4a..65d2677b8d 100755 --- a/python_smi_tools/rocm_smi.py +++ b/python_smi_tools/rocm_smi.py @@ -50,7 +50,7 @@ except ImportError: # Hash version - Shortened commit hash. Print here and not with lib for consistency with amd-smi SMI_MAJ = 2 SMI_MIN = 3 -SMI_PAT = 0 +SMI_PAT = 1 # SMI_HASH is provided by rsmiBindings __version__ = '%s.%s.%s+%s' % (SMI_MAJ, SMI_MIN, SMI_PAT, SMI_HASH)