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

[Build] Report an error while using comfyui “CUDA_PATH is set but CUDA wasnt able to be loaded” #21610

Closed
XGCoder opened this issue Aug 4, 2024 · 4 comments
Labels
build build issues; typically submitted using template ep:CUDA issues related to the CUDA execution provider

Comments

@XGCoder
Copy link

XGCoder commented Aug 4, 2024

Describe the issue

Hello, comfyui is reporting an error while using it

Error occurred when executing Image Rembg (Remove Background):

D:\a\_work\1\s\onnxruntime\python\onnxruntime_pybind_state.cc:891 onnxruntime::python::CreateExecutionProviderInstance CUDA_PATH is set but CUDA wasnt able to be loaded. Please install the correct version of CUDA andcuDNN 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.

My Cuda current environment:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Wed_Apr_17_19:36:51_Pacific_Daylight_Time_2024
Cuda compilation tools, release 12.5, V12.5.40
Build cuda_12.5.r12.5/compiler.34177558_0

My ComfyUI Version is the latest version

What I tried after this problem occurred:

Refer to this link to perform some necessary installation, but it did not take effect after restarting the computer

0.  conda avtivate stable 
1.  conda install pytorch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 pytorch-cuda=11.8 -c pytorch -c nvidia
2.  pip install torch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 --index-url https://download.pytorch.org/whl/cu118
3.  Download cuDNN   [Download cuDNN v8.9.7 (December 5th, 2023), for CUDA 12.x] [Windows build](https://developer.nvidia.com/downloads/compute/cudnn/secure/8.9.7/local_installers/12.x/cudnn-windows-x86_64-8.9.7.29_cuda12-archive.zip/) 
4.  Copy and paste it in the local CUDA/v12.5 corresponding directory

Urgency

No response

Target platform

Windows11

Build script

.

Error / output

image

Visual Studio Version

No response

GCC / Compiler Version

No response

@XGCoder XGCoder added the build build issues; typically submitted using template label Aug 4, 2024
@github-actions github-actions bot added the ep:CUDA issues related to the CUDA execution provider label Aug 4, 2024
@tianleiwu
Copy link
Contributor

tianleiwu commented Aug 4, 2024

I saw that you install pytorch for cuda 11.8, but use cudnn for cuda 12.x, they are not compatible.
You can use same cuda and cudnn major version in PyTorch and Onnxruntime.

For example, you can choose one of the following:

CUDA 11.x

  • Pytorch 2.2 up to 2.3.1 for cuda 11.8 (cuDNN 8.9 is used in torch < 2.4).
  • CUDA 11.8
  • cuDNN 8.9 for cuda 11
  • onnxruntime built with cuda 11.8 and cudnn 8.9, like pip install onnxruntime-gpu==1.18.1

CUDA 12.x

  • Pytorch 2.4.0 for cuda 12.1 or 12.4 (cuDNN 9.x is compatible with torch >= 2.4).
  • CUDA 12.x
  • cuDNN 9.x for cuda 12
  • onnxruntime built with cuda 12.x and cudnn 9.x, like pip install onnxruntime-gpu==1.18.1 --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/

For Windows, you will need install latest VC Runtime as well.

See https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements for more info.

@alivelee
Copy link

alivelee commented Aug 5, 2024

i encounter the same error, indeed the torch version is incompatible for cuda

@XGCoder
Copy link
Author

XGCoder commented Aug 5, 2024

I saw that you install pytorch for cuda 11.8, but use cudnn for cuda 12.x, they are not compatible. You can use same cuda and cudnn major version in PyTorch and Onnxruntime.

For example, you can choose one of the following:

CUDA 11.x

  • Pytorch 2.2 up to 2.3.1 for cuda 11.8 (cuDNN 8.9 is used in torch < 2.4).
  • CUDA 11.8
  • cuDNN 8.9 for cuda 11
  • onnxruntime built with cuda 11.8 and cudnn 8.9, like pip install onnxruntime-gpu==1.18.1

CUDA 12.x

  • Pytorch 2.4.0 for cuda 12.1 or 12.4 (cuDNN 9.x is compatible with torch >= 2.4).
  • CUDA 12.x
  • cuDNN 9.x for cuda 12
  • onnxruntime built with cuda 12.x and cudnn 9.x, like pip install onnxruntime-gpu==1.18.1 --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/

For Windows, you will need install latest VC Runtime as well.

See https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements for more info.

@tianleiwu Hello, I have tried it but it does not solve my problem. How can I troubleshoot the version mismatch problem? What commands do I need to execute?

@XGCoder
Copy link
Author

XGCoder commented Aug 5, 2024

My problem was solved. My original configuration was installed in the stable environment of conda, but my comfyui was not running, so I had installed the correct version but still had problems.

If you still have problems locally, you can refer to this link

@XGCoder XGCoder closed this as completed Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build issues; typically submitted using template ep:CUDA issues related to the CUDA execution provider
Projects
None yet
Development

No branches or pull requests

3 participants