Skip to content

[BUG][pathfinder] Windows system search fails to find any CUDA DLL when CUDA_HOME/CUDA_PATH are not set #1781

@rwgk

Description

@rwgk

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:

  1. The application directory (Python's install directory)
  2. The system directory (System32)
  3. 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: LoadLibraryExW never finds the DLL in the first place, affecting all CTK libraries equally.

Why this went unnoticed

  • Our CI Windows test environments always have CUDA_HOME or CUDA_PATH set.
  • The CUDA_HOME/CUDA_PATH search step runs before system search and successfully locates the DLLs, so the PATH-based fallback was never exercised.

References

Metadata

Metadata

Assignees

Labels

P0High priority - Must do!bugSomething isn't workingcuda.pathfinderEverything related to the cuda.pathfinder module

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions