Repository navigation
Conversation
_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>
Author
|
Downstream report with the full investigation and reproduction details: pytorch/pytorch#204338 |
|
@shubskmr Could you please help review this code change? |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Linux,
pyzesloads the Level Zero loader from a hardcoded path:When the loader the runtime actually uses lives somewhere else in the standard search path (for example a newer loader installed under
/usr/localor shipped with oneAPI), pyzes pins the distro copy instead. AzesInitissued through that mismatched loader copy leaves the process in a state where the oneAPI Unified Runtime no longer enumerates the Level Zero platform at all. Any consumer that queries Sysman before initializing the runtime is then broken for the rest of the process lifetime.Reproduction
Machine: Intel Arc B580 (Battlemage), NEO 26.40.40196.8, two coexisting loaders:
/usr/lib/x86_64-linux-gnu/libze_loader.so.1— 1.16 (Ubuntulibze1package)/usr/local/lib/libze_loader.so.1— 1.35 (built from this repo), the copy the SYCL runtime resolvesPyTorch (both the 2.15.0+xpu wheel and a source build) routes
torch.xpu.device_count()through pyzes before XPU initialization:Calling
get_device_propertiesfirst works fine. A minimal SYCL probe confirms the mechanism outside PyTorch: afterdlopenof the distro loader pluszesInit/zesDriverGet/zesDeviceGetthrough it,sycl::platform::get_platforms()no longer lists the Level Zero platform; doing the same through the runtime's loader, or not callingzesInitat all, leaves enumeration intact. Replacing the distro loader file's contents with the newer loader also makes the failure disappear, confirming the trigger is which loader copy serves the Sysman calls.Fix
Load
libze_loader.so.1by SONAME on Linux so the dynamic linker resolves it through the standard search path (LD_LIBRARY_PATH, the ld.so cache, default directories) — the same copy every other consumer gets. The distro location remains reachable that way, so no supported configuration loses access to the loader.Testing
On the system above, with the distro 1.16 loader restored so both loaders coexist:
PYTHONPATH):pyzes.gpuLib._nameislibze_loader.so.1, the same sequence returns the B580 fromget_device_properties, and an XPU matmul runs correctly.This PR was prepared with the assistance of an AI coding tool and reviewed by the author.