cuda-python icon indicating copy to clipboard operation
cuda-python copied to clipboard

[pathfinder] Use `LOAD_WITH_ALTERED_SEARCH_PATH` for system DLL search on Windows

Open rwgk opened this issue 2 weeks ago • 2 comments

WIP WIP WIP — Bug discovered while testing suggested code for NVIDIA/numba-cuda#308

This fix was generated by Cursor. I still need to review it myself.

The bug went unnoticed because on Windows we always have CUDA_HOME or CUDA_PATH set in our testing.


When loading CUDA DLLs via system search on Windows, the previous approach using LoadLibraryExW with flags=0 would find the DLL on PATH but fail to locate its co-located dependencies (error 126).

This fix uses SearchPathW to first find the DLL's full path, then loads it with LOAD_WITH_ALTERED_SEARCH_PATH so Windows searches for dependencies starting from the DLL's directory.

rwgk avatar Jan 16 '26 06:01 rwgk