From f9a30e4c2c43745978223c5e77fed98cbd2da6c7 Mon Sep 17 00:00:00 2001 From: Aviral Nigam Date: Thu, 18 Jun 2026 12:59:26 +0530 Subject: [PATCH] fix: Load the loader dll not the umd lib directly Related-To: NEO-18719 Signed-off-by: Aviral Nigam --- bindings/sysman/python/source/pyzes.py | 55 ++++++++++++-------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/bindings/sysman/python/source/pyzes.py b/bindings/sysman/python/source/pyzes.py index 073e6ab6..5ba6bfaf 100644 --- a/bindings/sysman/python/source/pyzes.py +++ b/bindings/sysman/python/source/pyzes.py @@ -9,6 +9,8 @@ # Python bindings for the libze_intel_gpu.so / ze_intel_gpu.dll library ## +import glob +import os import sys import threading from ctypes import * @@ -69,45 +71,40 @@ def _LoadZeLibrary(): if sys.platform.startswith("linux"): libName = "/usr/lib/x86_64-linux-gnu/lib" + libName + ".so.1" else: - # Try multiple common locations for Windows Intel GPU drivers + libName = libName + ".dll" + + module_dir = os.path.dirname(os.path.abspath(__file__)) + system_root = os.environ.get("SystemRoot", r"C:\Windows") + possible_paths = [ - # Try system PATH first - libName + "64.dll", - # Common Intel GPU driver locations - r"C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_*\ze_intel_gpu64.dll", - r"C:\Windows\System32\DriverStore\FileRepository\igdlh64.inf_amd64_*\ze_intel_gpu64.dll", - # Try current directory - "ze_intel_gpu64.dll", + os.path.join(module_dir, libName), + os.path.join(system_root, "System32", libName), + r"C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_*\ze_loader.dll", + r"C:\Windows\System32\DriverStore\FileRepository\igdlh64.inf_amd64_*\ze_loader.dll", + libName, ] library_loaded = False + load_errors = [] for path in possible_paths: - if library_loaded: - break - - if "*" in path: - # Handle wildcard paths for driver store - import glob - - matching_paths = glob.glob(path) - for match_path in matching_paths: - try: - gpuLib = CDLL(match_path) - library_loaded = True - break - except OSError: - pass # Try next path - else: - # Try loading the library directly + candidate_matches = glob.glob(path) if "*" in path else [path] + if not candidate_matches: + load_errors.append(f"{path}: no matches found") + continue + for match_path in candidate_matches: try: - gpuLib = CDLL(path) + gpuLib = CDLL(match_path) library_loaded = True - except OSError: - pass # Try next path + break + except OSError as error: + load_errors.append(f"{match_path}: {error}") + if library_loaded: + break if not library_loaded: raise Exception( - f"Failed to load Intel GPU library. Tried paths: {possible_paths}" + "Failed to load Level Zero loader on Windows. " + f"Tried paths: {possible_paths}. Errors: {load_errors}" ) if sys.platform.startswith("linux"):