Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CUDA does not load on Windows #22000

Closed
koush opened this issue Sep 5, 2024 · 6 comments
Closed

CUDA does not load on Windows #22000

koush opened this issue Sep 5, 2024 · 6 comments
Labels
ep:CUDA issues related to the CUDA execution provider platform:windows issues related to the Windows platform

Comments

@koush
Copy link

koush commented Sep 5, 2024

Describe the issue

I want to preface that ONNX runtime + CUDA provider works fine on Ubuntu 22.04. However, the same machine booted into windows results in the following error (while PyTorch works):

2024-09-05 08:30:27.7810630 [E:onnxruntime:Default, provider_bridge_ort.cc:1992 onnxruntime::TryGetProviderInfo_CUDA] D:\a\_work\1\s\onnxruntime\core\session\provider_bridge_ort.cc:1637 onnxruntime::ProviderLibrary::Get [ONNXRuntimeError] : 1 : FAIL : LoadLibrary failed with error 126 "" when trying to load "C:\Users\koush\Desktop\work\.venv\Lib\site-packages\onnxruntime\capi\onnxruntime_providers_cuda.dll"

2024-09-05 08:30:27.7882169 [W:onnxruntime:Default, onnxruntime_pybind_state.cc:965 onnxruntime::python::CreateExecutionProviderInstance] Failed to create CUDAExecutionProvider. Require cuDNN 9.* and CUDA 12.*, and the latest MSVC runtime. Please install all dependencies as mentioned in the GPU requirements page (https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements), make sure they're in the PATH, and that your GPU is supported.

I have CUDA, CUDNN, and zlib installed and in path. MSVC runtime is also installed.

This was a clean windows install.

I think there's some dependency missing from the documentation.

To reproduce

Follow the onnxruntime-gpu instructions for windows. Try to load the CUDA provider.

Urgency

No response

Platform

Windows

OS Version

11

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.19.2 or 1.18.1

ONNX Runtime API

Python

Architecture

X64

Execution Provider

CUDA

Execution Provider Library Version

CUDA 12.4, CUDA 12.6, CUDA 11.8

@github-actions github-actions bot added ep:CUDA issues related to the CUDA execution provider platform:windows issues related to the Windows platform labels Sep 5, 2024
@tianleiwu
Copy link
Contributor

tianleiwu commented Sep 5, 2024

What's your PyTorch version? Try install latest PyTorch for cuda 12 (older version of PyTorch uses cudnn 8, which will not work properly with latest onnxruntime-gpu).

If you install other onnxruntime packages (like onnxruntime or onnxruntime-directml), you might uninstall them first.

Need add cuda and cudnn bin directories to PATH environment variable. Example is like

set PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\bin;C:\nvidia\cudnn-windows-x86_64-9.3.0.75_cuda12-archive\bin;%PATH%

Recommend the following combination:

If you cannot find the root cause, try Dependency Walker to open the DLL (You can use pip show onnxruntime-gpu to find the site package localtion, the DLL is under site-packages\onnxruntime\capi\onnxruntime_providers_cuda.dll). For example, the following shows that cuDNN dll has a question mark, which means it is not found based on current path setting:
image

@koush
Copy link
Author

koush commented Sep 9, 2024

I was testing with latest torch.

I'll check this combination sholrtly, but why is PyTorch necessary in the combination you listed Is that required my onmx runtime?

@tianleiwu
Copy link
Contributor

why is PyTorch necessary in the combination you listed Is that required my onmx runtime?

PyTorch is not required to run onnxruntime.
However, if you use both of them in same process, make sure they are compatible.

@koush
Copy link
Author

koush commented Sep 10, 2024

why is PyTorch necessary in the combination you listed Is that required my onmx runtime?

PyTorch is not required to run onnxruntime. However, if you use both of them in same process, make sure they are compatible.

Understood. I was not using them in the same process. I set up a second virtual env for verification of the CUDA/CUDNN installs.

@koush
Copy link
Author

koush commented Oct 2, 2024

I installed latest nvidia drivers, CUDA 12.6, and CUDNN 9.4 (I also had CUDNN 8.x installed at some point too). I noticed that the PATH set by NVIDIA's installer was using Program Files\NVIDIA\CUDNN\bin when it needed Progra Files\NVIDIA\CUDNN\bin\12.6 which is where the DLLS are located.

@koush koush closed this as completed Oct 2, 2024
@tianleiwu
Copy link
Contributor

tianleiwu commented Oct 2, 2024

That's good finding.

When I installed cudnn 9.4 with setup file, the DLLs are in
C:\Program Files\NVIDIA\CUDNN\v9.4\bin\11.8
C:\Program Files\NVIDIA\CUDNN\v9.4\bin\12.6
And PATH has "C:\Program Files\NVIDIA\CUDNN\v9.4\bin", so I need manually change the PATH setting according to cuda 12 version "C:\Program Files\NVIDIA\CUDNN\v9.4\bin\12.6".

I usually use the tarball (zip file) to install cuDNN, which does not have such issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ep:CUDA issues related to the CUDA execution provider platform:windows issues related to the Windows platform
Projects
None yet
Development

No branches or pull requests

2 participants