Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

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

xxxliqu1dxxx3cda075b5152
diff --git a/setup.py b/setup.py
index 0213d6c42..c1a06ab6b 100644
--- a/setup.py
+++ b/setup.py
@@ -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
diff --git a/tools/test_setup_amd.py b/tools/test_setup_amd.py
index cd8536542..fa2847b5a 100644
--- a/tools/test_setup_amd.py
+++ b/tools/test_setup_amd.py
@@ -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"))