modelscope / DiffSynth-Studio

Enjoy the magic of Diffusion models!
Apache License 2.0
5.51k stars 502 forks source link

[ERROR] AssertionError: Torch not compiled with CUDA enabled #57

Open phanhavn opened 1 week ago

phanhavn commented 1 week ago

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!

itxTouseef74 commented 1 week ago

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

Artiprocher commented 1 week ago

@itxTouseef74 Yes. Thanks.

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

mqhamdam commented 6 days ago

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 commented 6 days ago

Seems duplicated of #52 I will try solution described there

itxTouseef74 commented 6 days ago

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 .

mqhamdam commented 6 days ago

@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!

poborin commented 6 days ago

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?

itxTouseef74 commented 5 days ago

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.