From 012c832b0d4e6157af6c133732c54a964d3cbfee Mon Sep 17 00:00:00 2001 From: "Wei (Will) Feng" <134637289+weifengpy@users.noreply.github.com> Date: Tue, 10 Nov 2026 18:02:21 -0800 Subject: [PATCH] pyzes: load the Level Zero loader by SONAME on Linux _LoadZeLibrary hardcoded /usr/lib/x86_64-linux-gnu/libze_loader.so.1 on Linux. When a different (e.g. newer) loader is the one the Level Zero runtime resolves through the standard search path - common when oneAPI or a locally built loader is installed under /usr/local or /opt - pyzes pins the distro copy instead. A zesInit issued through that mismatched loader leaves the process in a state where the Unified Runtime no longer enumerates the Level Zero platform, which breaks downstream consumers that query Sysman before initializing the runtime. torch.xpu.device_count() is one such consumer: after it runs, torch.xpu.get_device_properties() fails with "No XPU devices are available" on a healthy Intel Arc B580 system. Load libze_loader.so.1 by SONAME instead, so the dynamic linker picks the same loader copy as every other consumer. The distro location remains reachable through the standard search path. This commit was authored with the assistance of an AI coding tool. Signed-off-by: Wei (Will) Feng <134637289+weifengpy@users.noreply.github.com> --- bindings/sysman/python/source/pyzes/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bindings/sysman/python/source/pyzes/__init__.py b/bindings/sysman/python/source/pyzes/__init__.py index 823f73f3..c675c960 100644 --- a/bindings/sysman/python/source/pyzes/__init__.py +++ b/bindings/sysman/python/source/pyzes/__init__.py @@ -69,7 +69,14 @@ def _LoadZeLibrary(): # load the library libName = "ze_loader" if sys.platform.startswith("linux"): - libName = "/usr/lib/x86_64-linux-gnu/lib" + libName + ".so.1" + # Load by SONAME so the dynamic linker resolves the loader + # through the standard search path (LD_LIBRARY_PATH, the + # ld.so cache, default directories). Hardcoding one distro + # location can pin an older loader than the one the Level + # Zero runtime itself uses when several loaders coexist, + # and a zesInit through the mismatched copy can break + # device enumeration for the whole process. + libName = "lib" + libName + ".so.1" else: libName = libName + ".dll"