setup (AMD, Linux): the engine probes get the engine's lib_dirs on LD_LIBRARY_PATH (#3305)

engine_env put the ROCm library folders first on PATH, which only Windows' loader reads. On AMD Linux strata --families exited 127 on
libhipblas.so.3, so setup falsely said the engine does not run Qwen3.6. On Linux and elsewhere the folders now go first on LD_LIBRARY_PATH
(an existing value is kept); Windows keeps PATH. Ported from PR #3305 by xxxliqu1dxxx (resubmission of #2914), with its tests.
This commit is contained in:
xxxliqu1dxxx authored and Niko1221 committed 2026-10-26 18:23:22 +01:00
1 parent cc2c628cbe
commit 3cda075b51
2 files changed
+23 -7

No files matched your search

+7 -3
View File
@@ -4197,12 +4197,16 @@ def amd_gpus_windows(adapters=None, registry=None) -> list[dict]:
def engine_env(eng: Path) -> dict:
"""The environment for running an installed engine's own programs (`strata --families`, `strata-device
--list-devices`): the ready-made Windows HIP engine keeps hipblas.dll / libhipblaslt.dll in its rocm/bin, which the
loader finds through PATH only (#2372: a launch without it shows a "not found" dialog per DLL and prints nothing)."""
--list-devices`): the engine's ROCm library folders (its BUILD.json "lib_dirs") first on the dynamic-library path -
on Windows that is PATH, where the ready-made HIP engine keeps hipblas.dll / libhipblaslt.dll in its rocm/bin and the
loader finds them only through PATH (#2372: a launch without it shows a "not found" dialog per DLL and prints
nothing); on Linux and elsewhere it is LD_LIBRARY_PATH, where a probe without it exits 127 on libhipblas.so.3 and
prints nothing."""
env = dict(os.environ)
dirs = [str(d) for d in hip_lib_dirs(eng)]
if dirs:
env["PATH"] = os.pathsep.join(dirs + [env.get("PATH", "")])
var = "PATH" if os.name == "nt" else "LD_LIBRARY_PATH"
env[var] = os.pathsep.join(dirs + ([env[var]] if env.get(var) else []))
return env
+16 -4
View File
@@ -675,14 +675,25 @@ class EngineLaunchEnv(unittest.TestCase):
(eng / "BUILD.json").write_text('{"backend": "hip", "lib_dirs": ["rocm/bin"]}', encoding="utf-8")
return eng
def test_engine_env_puts_rocm_bin_first(self):
def test_engine_env_puts_rocm_bin_first_on_windows(self):
with tempfile.TemporaryDirectory() as t:
eng = self.engine(Path(t))
with mock.patch.dict("os.environ", {"PATH": "C:\\Windows"}):
with mock.patch.dict("os.environ", {"PATH": "C:\\Windows"}), \
mock.patch.object(setup.os, "name", "nt"):
env = setup.engine_env(eng)
self.assertEqual(env["PATH"].split(setup.os.pathsep)[0], str(eng / "rocm" / "bin"))
self.assertTrue(env["PATH"].endswith("C:\\Windows"))
def test_engine_env_puts_rocm_bin_first_on_ld_library_path(self):
with tempfile.TemporaryDirectory() as t:
eng = self.engine(Path(t))
with mock.patch.dict("os.environ", {"PATH": "/usr/bin", "LD_LIBRARY_PATH": "/usr/lib"}), \
mock.patch.object(setup.os, "name", "posix"):
env = setup.engine_env(eng)
self.assertEqual(env["LD_LIBRARY_PATH"].split(setup.os.pathsep)[0], str(eng / "rocm" / "bin"))
self.assertTrue(env["LD_LIBRARY_PATH"].endswith("/usr/lib"))
self.assertEqual(env["PATH"], "/usr/bin")
def test_engine_without_lib_dirs_keeps_the_environment(self):
with tempfile.TemporaryDirectory() as t:
with mock.patch.dict("os.environ", {"PATH": "/usr/bin"}):
@@ -696,7 +707,8 @@ class EngineLaunchEnv(unittest.TestCase):
return mock.Mock(stdout="qwen4exp qwen35moe\n")
with tempfile.TemporaryDirectory() as t:
eng = self.engine(Path(t))
with mock.patch.object(setup.subprocess, "run", fake_run):
with mock.patch.object(setup.subprocess, "run", fake_run), \
mock.patch.object(setup.os, "name", "nt"):
names = setup.engine_families(eng)
self.assertEqual(names, {"qwen4exp", "qwen35moe"})
self.assertEqual(seen["cmd"][1], "--families")
@@ -712,7 +724,7 @@ class EngineLaunchEnv(unittest.TestCase):
eng = self.engine(Path(t))
probe = eng / ("strata-device.exe" if setup.WIN else "strata-device")
probe.write_text("x")
with mock.patch.object(setup.subprocess, "run", fake_run), mock.patch.object(setup, "hip_runtime_beside_exe", lambda d: None):
with mock.patch.object(setup.subprocess, "run", fake_run), mock.patch.object(setup, "hip_runtime_beside_exe", lambda d: None), mock.patch.object(setup.os, "name", "nt"):
found = setup.hip_devices(probe)
self.assertEqual(found[0]["arch"], "gfx1100")
self.assertEqual(seen["env"]["PATH"].split(setup.os.pathsep)[0], str(eng / "rocm" / "bin"))