diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index 6b611f2f28..4258614956 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -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: diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py b/projects/amdsmi/py-interface/amdsmi_wrapper.py index 25fa782ec1..77f9a5cea7 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py @@ -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: diff --git a/projects/amdsmi/tools/generator.py b/projects/amdsmi/tools/generator.py index 46852e55f2..37d0014d1d 100644 --- a/projects/amdsmi/tools/generator.py +++ b/projects/amdsmi/tools/generator.py @@ -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: