Skip to content

[FEA]: Trigger add_dll_directory(found_path) logic even if was_already_loaded_from_elsewhere is true #821

Closed

Description

@gmarkall

Is this a duplicate?

Type of Bug

Runtime Error

Component

cuda.bindings

Describe the bug

Attempting to use NVRTC on Windows with the NVRTC wheels from cuda-python fails with:

nvrtc: error: failed to open nvrtc-builtins64_129.dll.
  Make sure that nvrtc-builtins64_129.dll is installed correctly.

I can work around this by copying nvrtc-builtins64_129.dll to a folder where other loaded DLLs exist, e.g.

copy "$SYS_PREFIX\Lib\site-packages\nvidia\cuda_nvrtc\bin\nvrtc-builtins64_*.dll" "$SYS_PREFIX"

How to Reproduce

I will have to create a smaller reproducer, but I observed this by pip installing Numba-CUDA in CI and running its testsuite: https://github.com/NVIDIA/numba-cuda/pull/353/files#diff-9753d897094baa6cf320a53ee98e7059f8477dbf3c6d467078ce35bcf3354f57R31-R57

Example run: https://github.com/NVIDIA/numba-cuda/actions/runs/16526296179/job/46740959886#step:8:8351

I did similar on my local machine and observed the same issue. I will update this issue once I have a shorter reproducer.

Expected behavior

Using NVRTC should not emit an NVRTC error about loading the builtins.

Operating System

Windows 11, amd64

nvidia-smi output

+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 572.13                 Driver Version: 572.13         CUDA Version: 12.8     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                  Driver-Model | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  Tesla T4                     TCC   |   00000001:00:00.0 Off |                  Off |
| N/A   38C    P8              9W /   70W |       9MiB /  16384MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+

Activity

  1. gmarkall commented on Aug 8, 2025

    @gmarkall
    ContributorAuthor

    As discussed in Slack, this is probably because Numba-CUDA has a couple of routes by which it opens NVRTC itself, but then attempts to use the CUDA bindings to actually compile programs.

  2. leofang commented on Aug 8, 2025

    @leofang
    Member

    This is how the NVRTC wheel is supported in cuda-bindings/cuda-core:

    Now to expand what Graham noted above:

    This seems like a very sharp edge in pathfinder, for which I am not sure if it's fixable at all. In an offline discussion, @rwgk suggested:

    We could make it so that the add_dll_directory(found_path) logic is triggered even if was_already_loaded_from_elsewhere is true. It'll still (and unavoidably) be a side effect, but a more consistent one.

  3. added
    triageNeeds the team's attention
    cuda.pathfinderEverything related to the cuda.pathfinder module
    and removed
    bugSomething isn't working
    on Aug 8, 2025
  4. gmarkall commented on Aug 8, 2025

    @gmarkall
    ContributorAuthor

    Numba-cuda should not be loading nvrtc at all when using the cuda bindings, so if I fix that problem then I think we should avoid this sharp edge?

  5. leofang commented on Aug 8, 2025

    @leofang
    Member

    Yes that'd be ideal.

  6. leofang commented on Aug 8, 2025

    @leofang
    Member

    I keep this issue open for now (until Ralf makes a decision) just because I have a feeling that numba-cuda might not be the only one that gets trapped by this.

  7. changed the title [-][BUG]: Attempting to use NVRTC on Windows with the NVRTC wheels from cuda-python fails to load NVRTC builtins[/-] [+][cuda_pathfinder][FEAT]: Trigger `add_dll_directory(found_path)` logic even if `was_already_loaded_from_elsewhere` is true[/+] on Aug 11, 2025
  8. changed the title [-][cuda_pathfinder][FEAT]: Trigger `add_dll_directory(found_path)` logic even if `was_already_loaded_from_elsewhere` is true[/-] [+][FEA]: Trigger `add_dll_directory(found_path)` logic even if `was_already_loaded_from_elsewhere` is true[/+] on Aug 12, 2025
  9. carterbox commented on Aug 15, 2025

    @carterbox
    Contributor

    I think nvmath-python is also catching this issue in our attempted migration to pathfinder. We tried to resolve this by calling pathfinder.load_nvidia_dynamic_lib('nvrtc-builtins'), but I believe this doesn't work because nvrtc-builtins is not in SUPPORTED_NVIDIA_LIBNAMES.

    Would supporting loading nvrtc-builtins separately from nvrtc solve the issue?

  10. leofang commented on Aug 15, 2025

    @leofang
    Member

    @carterbox it must be a bug in your environment and it is hard to triage for you without further information. NVRTC is properly supported as explained above. You don't need to additionally load nvrtc-builtin yourself.

  11. ZzEeKkAa commented on Aug 18, 2025

    @ZzEeKkAa
    Contributor

    @leofang @carterbox I was able to reproduce the issue with nvrtc-builtins and filed a separate issue with all details: #849

  12. added
    enhancementAny code-related improvements
    and removed
    triageNeeds the team's attention
    on Aug 19, 2025
  13. moved this from Todo to Done in CCCLon Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

cuda.pathfinderEverything related to the cuda.pathfinder moduleenhancementAny code-related improvements

Type

No type

Projects

  • Status
    Done

Relationships

None yet

Development

No branches or pull requests

Issue actions