-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
ONNX preloaded dlls are incompatible with CUDNN torch version #24266
Comments
See example 2 in https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#compatibility-with-pytorch If you want to use a different version of cuDNN 9.x in PyTorch and OnnxRuntime, I have no idea since there is potential conflicts. |
Hi @tianleiwu, In the documentation is stated If you don't put any preload, onnx already falls back to the cudnn available with torch, in which situation preload should be used if torch is already available? I understand that I can upgrade torch to the latest version but I was aiming to avoid exactly that |
If you do not use preload_dlls(), onnxruntime will try search cuda and cudnn DLL based on PATH setting. It is not likely that user will add pytorch lib directory to PATH. PyTorch will always load from its lib directory in Windows. If onnxruntime is imported before torch in Windows, it is recommended to use preload_dlls() to avoid potential conflicts. The potential conflicts for different versions of cudnn 9.x: The preload_dlls() is a function in Python, the source is here: onnxruntime/onnxruntime/__init__.py Line 241 in 24620e7
@lorenzomammana, you can try modify the function and see whether you can make it to work for your purpose. |
Hi @tianleiwu I've done a few more experiments. First as you have suggested I've tried changing the preload_dll function to preload also the library that's giving error, but I can't cheat it in this way and the error arise again. Then I've tried preloading different versions of CUDNN without preloading cuda dlls (so fallback to cu121 from torch) Results are the following: Cudnn 9.1.1 -> Success in loading torch but then I get I would have honestly expected that preloding 9.1.1 which is in the same minor range of my torch (9.1.0) should have worked 😅 |
Try add all cudnn_*.dll to preload list (Currently only cudnn_cnn64_9.dll is added). That might walkaround the issue. |
Describe the issue
Hi,
I'm trying to do something I'm starting to think it is not possible... which is using a CUDNN that is different between torch and onnx.
In the past I was using torch 2.1.2+cu121 and onnxruntime 1.20.0, with this configuration, given the fact that torch was shipping with cudnn8 I had to manually install cudnn 9 to use onnx.
While doing this I've realized that cudnn 9.1 makes a few model much slower compared to cudnn9.6, so I upgraded to 9.6 and everything was working fine.
Now we decided to upgrade the torch version to 2.4.1+cu121 which ships with cudnn 9.1 that is used by onnxruntime making a few of my models effectively slower..
So I'm trying to use the new preload_dlls api to load cudnn 9.6 before importing torch, but when I import torch I get
This is a list of preloaded dlls before importing torch
And after torch
Am I correct to assume that cudnn_cnn64_9.dll is causing errors as it is incompatible? Any clue on why there are other libraries loaded correctly from torch?
I've tried both preloading cuda and cudnn or only cudnn and use torch cuda but the issue is the same
To reproduce
On windows with Cuda 12.6 and CUDNN 9.6.0 installed
Urgency
It heavily slowdowns (like 2 times slower) a few of the models we use
Platform
Windows
OS Version
Windows 10
ONNX Runtime Installation
Released Package
ONNX Runtime Version or Commit ID
1.21.0
ONNX Runtime API
Python
Architecture
X64
Execution Provider
CUDA
Execution Provider Library Version
CUDA 12.6 on Windows, Cuda 12.1 from torch
The text was updated successfully, but these errors were encountered: