Skip to content

Commit bd5b7fd

Browse files
authored
[AMD] Load libhipblaslt with rocm_sdk lib if installed via wheels (#9614)
When TheRock wheels are used, libhipblaslt is inside the python venv that contains the installed wheels. Since it's not in /opt/rocm anymore, the user would have to set LD_LIBRARY_PATH to `$(rocm-sdk path root)/lib`. This patch avoids this by calling `rocm_sdk`'s `preload_libraries` directly. If TheRock wheels aren't use, it'll fallback to the original search method. This will make the tests in `python/test/unit/runtime/test_blaslt.py` pass when TheRock based wheels are used.
1 parent eb70647 commit bd5b7fd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

third_party/amd/python/triton_amd.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,16 @@ void init_triton_amd(py::module &&m) {
550550
});
551551

552552
auto hipBlas = m.def_submodule("hipblas");
553+
// For ROCm installed via TheRock wheels: Preload hipblaslt library via
554+
// rocm_sdk if available. When using TheRock wheel installs, libhipblaslt
555+
// resides within the Python wheel package rather than in the standard
556+
// /opt/rocm/lib location. This preload ensures the library is properly
557+
// loaded before HipblasLtInstance tries to dlopen it, allowing the dynamic
558+
// linker to find it from the ROCm wheel's bundled libraries.
559+
try {
560+
py::module_::import("rocm_sdk").attr("preload_libraries")("hipblaslt");
561+
} catch (...) {
562+
}
553563
py::class_<HipblasLtInstance>(hipBlas, "HipblasLt")
554564
.def(py::init<>([&](py::object &workspace) {
555565
auto wrk_ptr = workspace.attr("data_ptr")().cast<uint64_t>();

0 commit comments

Comments
 (0)