Find libamd_smi.so and librocm-core.so relative to wrapper.py

Allow amdsmi to find libamd_smi.so and librocm-core.so relative to
amdsmi_wrapper.py location.

The amdsmi_wrapper.py file is located in
_rocm_sdk_core/share/amd_smi/amdsmi and the libraries are in
_rocm_sdk_core/lib/libamd_smi.so.26.
_rocm_sdk_core/lib/librocm-core.so.1.


[ROCm/amdsmi commit: ad20d57162]
This commit is contained in:
Galantsev, Dmitrii
2025-10-29 18:10:38 -05:00
committato da Galantsev, Dmitrii
parent 9973a6b324
commit 55f999f3ce
3 ha cambiato i file con 20 aggiunte e 0 eliminazioni
@@ -5511,6 +5511,12 @@ def amdsmi_get_rocm_version()-> Tuple[bool, str]:
try:
possible_locations = list()
# 0. Relative to amdsmi_interface.py in TheRock:
# `amdsmi_interface.py` is located in
# `_rocm_sdk_core/share/amd_smi/amdsmi`, libraries are in
# `_rocm_sdk_core/lib`.
librocm_core_path = Path(__file__).resolve().parent.parent.parent.parent / "lib/librocm-core.so"
possible_locations.append(librocm_core_path)
# 1.
rocm_path = os.getenv("ROCM_HOME", os.getenv("ROCM_PATH"))
if rocm_path:
@@ -167,6 +167,10 @@ _libraries = {}
from pathlib import Path
# libamd_smi.so can be located in several different places.
# Look for it with below priority:
# 0. Relative to amdsmi_wrapper.py in TheRock:
# `amdsmi_wrapper.py` is located in
# `_rocm_sdk_core/share/amd_smi/amdsmi`, libraries are in
# `_rocm_sdk_core/lib`.
# 1. ROCM_HOME/ROCM_PATH environment variables
# - ROCM_HOME/lib
# - ROCM_PATH/lib (usually set to /opt/rocm/)
@@ -179,6 +183,9 @@ from pathlib import Path
def find_smi_library():
err = OSError("Could not load libamd_smi.so")
possible_locations = []
# 0.
libamd_smi_path = Path(__file__).resolve().parent.parent.parent.parent / "lib/libamd_smi.so"
possible_locations.append(libamd_smi_path)
# 1.
rocm_path = os.getenv("ROCM_HOME", os.getenv("ROCM_PATH"))
if rocm_path:
+7
Vedi File
@@ -182,6 +182,10 @@ def main():
new_line = f"""from pathlib import Path
# {library_name} can be located in several different places.
# Look for it with below priority:
# 0. Relative to amdsmi_wrapper.py in TheRock:
# `amdsmi_wrapper.py` is located in
# `_rocm_sdk_core/share/amd_smi/amdsmi`, libraries are in
# `_rocm_sdk_core/lib`.
# 1. ROCM_HOME/ROCM_PATH environment variables
# - ROCM_HOME/lib
# - ROCM_PATH/lib (usually set to /opt/rocm/)
@@ -194,6 +198,9 @@ def main():
def find_smi_library():
err = OSError("Could not load {library_name}")
possible_locations = []
# 0.
libamd_smi_path = Path(__file__).resolve().parent.parent.parent.parent / "lib/libamd_smi.so"
possible_locations.append(libamd_smi_path)
# 1.
rocm_path = os.getenv("ROCM_HOME", os.getenv("ROCM_PATH"))
if rocm_path: