DiffSynth-Studio icon indicating copy to clipboard operation
DiffSynth-Studio copied to clipboard

[ERROR] AssertionError: Torch not compiled with CUDA enabled

Open phanhavn opened this issue 1 year ago • 8 comments

Hi there, After run command "python -m streamlit run DiffSynth_Studio.py", the webpage showing with this error: "AssertionError: Torch not compiled with CUDA enabled"

image

How to resolve it, thank you so much!

phanhavn avatar Jun 26 '24 15:06 phanhavn

To resolve this issue you have to install Cuda use this command pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

itxTouseef74 avatar Jun 26 '24 16:06 itxTouseef74

@itxTouseef74 Yes. Thanks.

@phanhavn Please see the official website of Pytorch: https://pytorch.org/.

Artiprocher avatar Jun 27 '24 01:06 Artiprocher

Am I doing something wrong? Still getting error Torch not compiled with CUDA enabled

# python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 --user
DEPRECATION: Loading egg at c:\users\pc\appdata\roaming\python\python311\site-packages\h2-2.6.2-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation. Discussion can be found at https://github.com/pypa/pip/issues/12330
DEPRECATION: Loading egg at c:\users\pc\appdata\roaming\python\python311\site-packages\hpack-3.0.0-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation. Discussion can be found at https://github.com/pypa/pip/issues/12330  
DEPRECATION: Loading egg at c:\users\pc\appdata\roaming\python\python311\site-packages\hyperframe-3.2.0-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation. Discussion can be found at https://github.com/pypa/pip/issues/12330
DEPRECATION: Loading egg at c:\users\pc\appdata\roaming\python\python311\site-packages\ksql-0.10.2-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation. Discussion can be found at https://github.com/pypa/pip/issues/12330  
DEPRECATION: Loading egg at c:\python311\lib\site-packages\hyper-0.7.0-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation. Discussion can be found at https://github.com/pypa/pip/issues/12330
DEPRECATION: Loading egg at c:\python311\lib\site-packages\ksql-0.10.2-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation. Discussion can be found at https://github.com/pypa/pip/issues/12330
Looking in indexes: https://download.pytorch.org/whl/cu118
Requirement already satisfied: torch in c:\python311\lib\site-packages (2.1.1+cu118)
Requirement already satisfied: torchvision in c:\users\pc\appdata\roaming\python\python311\site-packages (0.16.1)
Requirement already satisfied: torchaudio in c:\users\pc\appdata\roaming\python\python311\site-packages (2.1.1+cu118)
Requirement already satisfied: filelock in c:\python311\lib\site-packages (from torch) (3.13.1)
Requirement already satisfied: typing-extensions in c:\users\pc\appdata\roaming\python\python311\site-packages (from torch) (4.8.0)
Requirement already satisfied: sympy in c:\python311\lib\site-packages (from torch) (1.12)
Requirement already satisfied: networkx in c:\python311\lib\site-packages (from torch) (3.2.1)
Requirement already satisfied: jinja2 in c:\python311\lib\site-packages (from torch) (3.1.2)
Requirement already satisfied: fsspec in c:\python311\lib\site-packages (from torch) (2023.10.0)
Requirement already satisfied: numpy in c:\python311\lib\site-packages (from torchvision) (1.26.2)
Requirement already satisfied: requests in c:\python311\lib\site-packages (from torchvision) (2.31.0)
Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in c:\users\pc\appdata\roaming\python\python311\site-packages (from torchvision) (10.0.1)
Requirement already satisfied: MarkupSafe>=2.0 in c:\python311\lib\site-packages (from jinja2->torch) (2.1.3)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\python311\lib\site-packages (from requests->torchvision) (3.2.0)
Requirement already satisfied: idna<4,>=2.5 in c:\python311\lib\site-packages (from requests->torchvision) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in c:\python311\lib\site-packages (from requests->torchvision) (1.26.16)
Requirement already satisfied: certifi>=2017.4.17 in c:\python311\lib\site-packages (from requests->torchvision) (2023.7.22)
Requirement already satisfied: mpmath>=0.19 in c:\python311\lib\site-packages (from sympy->torch) (1.3.0)

mqhamdam avatar Jun 27 '24 09:06 mqhamdam

Seems duplicated of #52 I will try solution described there

mqhamdam avatar Jun 27 '24 09:06 mqhamdam

Am I doing something wrong? Still getting error Torch not compiled with CUDA enabled

# python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 --user
DEPRECATION: Loading egg at c:\users\pc\appdata\roaming\python\python311\site-packages\h2-2.6.2-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation. Discussion can be found at https://github.com/pypa/pip/issues/12330
DEPRECATION: Loading egg at c:\users\pc\appdata\roaming\python\python311\site-packages\hpack-3.0.0-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation. Discussion can be found at https://github.com/pypa/pip/issues/12330  
DEPRECATION: Loading egg at c:\users\pc\appdata\roaming\python\python311\site-packages\hyperframe-3.2.0-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation. Discussion can be found at https://github.com/pypa/pip/issues/12330
DEPRECATION: Loading egg at c:\users\pc\appdata\roaming\python\python311\site-packages\ksql-0.10.2-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation. Discussion can be found at https://github.com/pypa/pip/issues/12330  
DEPRECATION: Loading egg at c:\python311\lib\site-packages\hyper-0.7.0-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation. Discussion can be found at https://github.com/pypa/pip/issues/12330
DEPRECATION: Loading egg at c:\python311\lib\site-packages\ksql-0.10.2-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation. Discussion can be found at https://github.com/pypa/pip/issues/12330
Looking in indexes: https://download.pytorch.org/whl/cu118
Requirement already satisfied: torch in c:\python311\lib\site-packages (2.1.1+cu118)
Requirement already satisfied: torchvision in c:\users\pc\appdata\roaming\python\python311\site-packages (0.16.1)
Requirement already satisfied: torchaudio in c:\users\pc\appdata\roaming\python\python311\site-packages (2.1.1+cu118)
Requirement already satisfied: filelock in c:\python311\lib\site-packages (from torch) (3.13.1)
Requirement already satisfied: typing-extensions in c:\users\pc\appdata\roaming\python\python311\site-packages (from torch) (4.8.0)
Requirement already satisfied: sympy in c:\python311\lib\site-packages (from torch) (1.12)
Requirement already satisfied: networkx in c:\python311\lib\site-packages (from torch) (3.2.1)
Requirement already satisfied: jinja2 in c:\python311\lib\site-packages (from torch) (3.1.2)
Requirement already satisfied: fsspec in c:\python311\lib\site-packages (from torch) (2023.10.0)
Requirement already satisfied: numpy in c:\python311\lib\site-packages (from torchvision) (1.26.2)
Requirement already satisfied: requests in c:\python311\lib\site-packages (from torchvision) (2.31.0)
Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in c:\users\pc\appdata\roaming\python\python311\site-packages (from torchvision) (10.0.1)
Requirement already satisfied: MarkupSafe>=2.0 in c:\python311\lib\site-packages (from jinja2->torch) (2.1.3)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\python311\lib\site-packages (from requests->torchvision) (3.2.0)
Requirement already satisfied: idna<4,>=2.5 in c:\python311\lib\site-packages (from requests->torchvision) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in c:\python311\lib\site-packages (from requests->torchvision) (1.26.16)
Requirement already satisfied: certifi>=2017.4.17 in c:\python311\lib\site-packages (from requests->torchvision) (2023.7.22)
Requirement already satisfied: mpmath>=0.19 in c:\python311\lib\site-packages (from sympy->torch) (1.3.0)

First uninstall the current PyTorch installation use this command pip uninstall torch torchaudio torchvision

Than install CUDA Toolkit .You can download it from the NVIDIA official site (https://developer.nvidia.com/cuda-toolkit).

Now reinstall PyTorch with CUDA support use command: pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

After that verify the installation that PyTorch is installed with CUDA support: To verify make a test file paste this code there and run file Here is code:

import torch print(torch.version.cuda) //And this should return version of cuda print(torch.cuda.is_available()) //This should return True

Than run project again this will solve your problem. I hope this answer will help you.

NOTE: The code i have provided this just to verify cudda support it is not part of application Thanks .

itxTouseef74 avatar Jun 27 '24 11:06 itxTouseef74

@itxTouseef74 yep, your solution works, I'm rarely using python thus didn't knew that pip wont replace package on upgrade, or it is just pytorch specific. Anyway thanks!

mqhamdam avatar Jun 28 '24 01:06 mqhamdam

I'm facing the same issue. However, I have a MacBook that do not support CUDA as it has an integrated GPU. How would one install it to Apple M1/2 silicone?

poborin avatar Jun 28 '24 04:06 poborin

I'm facing the same issue. However, I have a MacBook that do not support CUDA as it has an integrated GPU. How would one install it to Apple M1/2 silicone?

As this project requires CUDA, it won't run natively on MacBooks with Apple Silicon (M1/M2) since CUDA is not supported on these devices. Instead, you would need to use the Metal Performance Shaders (MPS) backend for GPU acceleration on macOS, which can be a complex and lengthy process.

itxTouseef74 avatar Jun 28 '24 09:06 itxTouseef74