AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
142.95k stars 26.94k forks source link

[Bug]: AttributeError: module 'torch' has no attribute 'cuda' #8233

Open filliptm opened 1 year ago

filliptm commented 1 year ago

Is there an existing issue for this?

What happened?

Everything was working well, I then proceeded to update some extensions, and when i restarted stable, I got this error message

Already up to date. venv "C:\ai\stable-diffusion-webui\venv\Scripts\Python.exe" Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] Commit hash: 0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8 Traceback (most recent call last): File "C:\ai\stable-diffusion-webui\launch.py", line 360, in prepare_environment() File "C:\ai\stable-diffusion-webui\launch.py", line 272, in prepare_environment run_python("import torch; assert torch.cuda.is_available(), 'Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'") File "C:\ai\stable-diffusion-webui\launch.py", line 129, in run_python return run(f'"{python}" -c "{code}"', desc, errdesc) File "C:\ai\stable-diffusion-webui\launch.py", line 105, in run raise RuntimeError(message) RuntimeError: Error running command. Command: "C:\ai\stable-diffusion-webui\venv\Scripts\python.exe" -c "import torch; assert torch.cuda.is_available(), 'Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'" Error code: 1 stdout: stderr: Traceback (most recent call last): File "", line 1, in AttributeError: module 'torch' has no attribute 'cuda'

Press any key to continue . . .

Steps to reproduce the problem

update some extensions, and when I restarted stable

What should have happened?

Normal boot up

Commit where the problem happens

0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8

What platforms do you use to access the UI ?

Windows

What browsers do you use to access the UI ?

Brave

Command Line Arguments

COMMANDLINE_ARGS= --no-half-vae --listen --api --xformers --share --autolaunch --disable-safe-unpickle --enable-insecure-extension-access --gradio-auth :

List of extensions

image

Console logs

Already up to date.
venv "C:\ai\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: 0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8
Traceback (most recent call last):
  File "C:\ai\stable-diffusion-webui\launch.py", line 360, in <module>
    prepare_environment()
  File "C:\ai\stable-diffusion-webui\launch.py", line 272, in prepare_environment
    run_python("import torch; assert torch.cuda.is_available(), 'Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'")
  File "C:\ai\stable-diffusion-webui\launch.py", line 129, in run_python
    return run(f'"{python}" -c "{code}"', desc, errdesc)
  File "C:\ai\stable-diffusion-webui\launch.py", line 105, in run
    raise RuntimeError(message)
RuntimeError: Error running command.
Command: "C:\ai\stable-diffusion-webui\venv\Scripts\python.exe" -c "import torch; assert torch.cuda.is_available(), 'Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'"
Error code: 1
stdout: <empty>
stderr: Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'torch' has no attribute 'cuda'

Press any key to continue . . .

Additional information

No response

vladmandic commented 1 year ago

torch cannot detect cuda anymore, most likely you'll need to reinstall torch. if update to an extension did this, please let us know - in my book, that kind of behavior is borderline hostile as extension should NOT change core libraries, only libraries that are extra for that extension.

filliptm commented 1 year ago

torch cannot detect cuda anymore, most likely you'll need to reinstall torch. if update to an extension did this, please let us know - in my book, that kind of behavior is borderline hostile as an extension should NOT change core libraries, only libraries that are extra for that extension.

This 100% happened after an extension update. I was showing a friend something and told him to update his extensions, and he got this error. Later in the night i did the same and got the same error. So something is definitely hostile as you said =P

econundrum commented 1 year ago

This happened to me too the last dreambooth update made some requirements change that screwed the python environment. I had to delete my venv folder in the end and let automatic1111 rebuild it. Seemed to resolve it for the other people on that thread earlier too.

filliptm commented 1 year ago

This happened to me too the last dreambooth update made some requirements change that screwed the python environment. I had to delete my venv folder in the end and let automatic1111 rebuild it. Seemed to resolve it for the other people on that thread earlier too.

Tried doing this and got another error =P Dreambooth can suck it.

Already up to date. venv "C:\ai\stable-diffusion-webui\venv\Scripts\Python.exe"

INCOMPATIBLE PYTHON VERSION

This program is tested with 3.10.6 Python, but you have 3.11.0. If you encounter an error with "RuntimeError: Couldn't install torch." message, or any other error regarding unsuccessful package (library) installation, please downgrade (or upgrade) to the latest version of 3.10 Python and delete current Python and "venv" folder in WebUI's directory.

You can download 3.10 Python from here: https://www.python.org/downloads/release/python-3109/

Alternatively, use a binary release of WebUI: https://github.com/AUTOMATIC1111/stable-diffusion-webui/releases

Use --skip-python-version-check to suppress this warning.

Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] Commit hash: 0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8 Installing torch and torchvision Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu117 ERROR: Could not find a version that satisfies the requirement torch==1.13.1+cu117 (from versions: none) ERROR: No matching distribution found for torch==1.13.1+cu117

[notice] A new release of pip available: 22.3 -> 23.0.1 [notice] To update, run: C:\ai\stable-diffusion-webui\venv\Scripts\python.exe -m pip install --upgrade pip Traceback (most recent call last): File "C:\ai\stable-diffusion-webui\launch.py", line 360, in prepare_environment() File "C:\ai\stable-diffusion-webui\launch.py", line 269, in prepare_environment run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True) File "C:\ai\stable-diffusion-webui\launch.py", line 89, in run raise RuntimeError(f"""{errdesc or 'Error running command'}. RuntimeError: Couldn't install torch. Command: "C:\ai\stable-diffusion-webui\venv\Scripts\python.exe" -m pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117 Error code: 1 Press any key to continue . . .

econundrum commented 1 year ago

Yes twice updates to dreambooth have screwed my python environment badly.

vladmandic commented 1 year ago

i actually reported that to dreambooth extension author 3 weeks ago and got told off. https://github.com/d8ahazard/sd_dreambooth_extension/issues/931

econundrum commented 1 year ago

yes I reported an issue yesterday and met with much the same response. I'm running without dreambooth now as I had to use CPU training anyway with my 4Gb card and they made that harder recently so I'd gone to Colab, which is much quicker anyway.

So I've ditched this extension for now, since I was no longer really using it anyway and updating it regularly breaks my Automatic1111 environment.

jwvanderbeck commented 1 year ago

Also happened to me and dreambooth was one of the ones that updated!

Dreambooth can take a hike. Deleted.