-
Notifications
You must be signed in to change notification settings - Fork 259
Description
Summary
On Windows, the pathfinder's load_with_system_search() fails to find all CUDA Toolkit DLLs when CUDA_HOME/CUDA_PATH are not set. The DLLs are on PATH but LoadLibraryExW never finds them.
Root cause
Python 3.8+ calls SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS) at process startup, which restricts LoadLibraryExW(name, NULL, 0) to searching only:
- The application directory (Python's install directory)
- The system directory (
System32) - Directories explicitly added via
AddDllDirectory()
PATH is excluded entirely. The current code calls LoadLibraryExW(dll_name, None, 0) with a bare DLL name, so it silently fails to find any CUDA DLL that isn't in one of those three locations.
Note: This was initially misdiagnosed as a dependency-resolution issue (error 126 for co-located DLLs like nvrtc-builtins). Experiments uncovered the problem is more fundamental:
LoadLibraryExWnever finds the DLL in the first place, affecting all CTK libraries equally.
Why this went unnoticed
- Our CI Windows test environments always have
CUDA_HOMEorCUDA_PATHset. - The
CUDA_HOME/CUDA_PATHsearch step runs before system search and successfully locates the DLLs, so thePATH-based fallback was never exercised.
References
- Context: discovered while testing suggested code for Use
pathfinderfor dynamic libraries numba-cuda#308