stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

[Bug]: RuntimeError: Couldn't install torch.

Open arkeence opened this issue 1 year ago • 15 comments

Checklist

  • [ ] The issue exists after disabling all extensions
  • [X] The issue exists on a clean installation of webui
  • [ ] The issue is caused by an extension, but I believe it is caused by a bug in the webui
  • [X] The issue exists in the current version of the webui
  • [ ] The issue has not been reported before recently
  • [X] The issue has been reported before but has not been fixed yet

What happened?

Screenshot 2024-07-15 163620 I have installed sd-v1-4.ckpt and GFPGAN 1.4. Now when I try to open it (WebUi-user.bat) it gives me this error. I tried to install manually but it doesn't work. I need it to work on AMD CPU.

image

Steps to reproduce the problem

  1. Open WebUi-user.bat

What should have happened?

It should have installed torch

What browsers do you use to access the UI ?

Mozilla Firefox

Sysinfo

The --dump-sysinfo dosen't work.

Console logs

venv "C:\Users\R\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)]
Version: v1.9.4
Commit hash: feee37d75f1b168768014e4634dcb156ee649c05
Installing torch and torchvision
C:\Users\R\stable-diffusion-webui\venv\Scripts\python.exe: No module named pip
Traceback (most recent call last):
  File "C:\Users\R\stable-diffusion-webui\launch.py", line 48, in <module>
    main()
  File "C:\Users\R\stable-diffusion-webui\launch.py", line 39, in main
    prepare_environment()
  File "C:\Users\R\stable-diffusion-webui\modules\launch_utils.py", line 380, in prepare_environment
    run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
  File "C:\Users\R\stable-diffusion-webui\modules\launch_utils.py", line 115, in run
    raise RuntimeError("\n".join(error_bits))
RuntimeError: Couldn't install torch.
Command: "C:\Users\R\stable-diffusion-webui\venv\Scripts\python.exe" -m pip install torch==2.1.2 torchvision==0.16.2 --extra-index-url https://download.pytorch.org/whl/cu121
Error code: 1
Press any key to continue . . .

Additional information

I have windows 11

arkeence avatar Jul 15 '24 13:07 arkeence

Can confirm on ARCH. Both when installed from AUR: aur/stable-diffusion-webui-git 1.9.4.r0.gfeee37d-2 (+0 0.00) (Installed: 1.9.4.r0.gfeee37d-3) and downloaded manually.

I attach log. Seems like some kind of available and required torch version mismatch? diffusion.log

Aleszp avatar Jul 17 '24 22:07 Aleszp

I'm having the same problem

pesado1 avatar Jul 18 '24 19:07 pesado1

Can confirm on ARCH. Both when installed from AUR: aur/stable-diffusion-webui-git 1.9.4.r0.gfeee37d-2 (+0 0.00) (Installed: 1.9.4.r0.gfeee37d-3) and downloaded manually.

I attach log. Seems like some kind of available and required torch version mismatch? diffusion.log

This is a separate issue from the original report. You are trying to run the script in a Python 3.12 environment, webui doesn't support that version, you need to install Python 3.10.6. If you don't want to downgrade your system python, just download the tarball of 3.10.6, make it and then replace

python_cmd="python3"

with

python_cmd="[PATH TO PYTHON3.10.6 EXECUTABLE]"

in webui.sh then run it and it should work.

FiratUsta avatar Jul 19 '24 12:07 FiratUsta

This is a separate issue from the original report (which I cannot help with). You are trying to run the script in a Python 3.12 environment, webui doesn't support that version, you need to install Python 3.10.6. If you don't want to downgrade your system python, just download the tarball of 3.10.6, make it and then replace

I've uninstalled Python 3.12 and installed 3.10.6 before installing Stable Diffusion.

But still is there a solution to fix my problem?

arkeence avatar Jul 19 '24 12:07 arkeence

This is a separate issue from the original report (which I cannot help with). You are trying to run the script in a Python 3.12 environment, webui doesn't support that version, you need to install Python 3.10.6. If you don't want to downgrade your system python, just download the tarball of 3.10.6, make it and then replace

I've uninstalled Python 3.12 and installed 3.10.6 before installing Stable Diffusion.

But still is there a solution to fix my problem?

My response was mostly aimed at Aleszp, as their logs suggest that they're using 3.12. Your case is different, you are correctly using 3.10.6, but looking at your logs it looks like you don't have pip? Can you open a cmd prompt and check the result of pip --version? If you don't get something like below, that means you don't have pip install which is necessary to install torch;

pip 22.2.1 from C:\Users\[USERNAME]\AppData\Local\Programs\Python\Python310\lib\site-packages\pip (python 3.10)

If you don't have pip, you can install it by looking at how-tos on the internet but the quickest and the easiest way is to:

  1. Run the Python 3.10.6 installer.
  2. Select the 'Modify' option.
  3. Make sure the checkbox next to 'pip' is selected, click next.
  4. Make sure 'Add Python to environment variables' is selected, click 'Install'.

When that's done, restart your PC and test pip --version again, if you see a version number you're good to go so you can run the batch file again and it should install.

FiratUsta avatar Jul 19 '24 14:07 FiratUsta

This is a separate issue from the original report (which I cannot help with). You are trying to run the script in a Python 3.12 environment, webui doesn't support that version, you need to install Python 3.10.6. If you don't want to downgrade your system python, just download the tarball of 3.10.6, make it and then replace

I've uninstalled Python 3.12 and installed 3.10.6 before installing Stable Diffusion. But still is there a solution to fix my problem?

My response was mostly aimed at Aleszp, as their logs suggest that they're using 3.12. Your case is different, you are correctly using 3.10.6, but looking at your logs it looks like you don't have pip? Can you open a cmd prompt and check the result of pip --version? If you don't get something like below, that means you don't have pip install which is necessary to install torch;

pip 22.2.1 from C:\Users\[USERNAME]\AppData\Local\Programs\Python\Python310\lib\site-packages\pip (python 3.10)

If you don't have pip, you can install it by looking at how-tos on the internet but the quickest and the easiest way is to:

1. Run the Python 3.10.6 installer.

2. Select the 'Modify' option.

3. Make sure the checkbox next to 'pip' is selected, click next.

4. Make sure 'Add Python to environment variables' is selected, click 'Install'.

When that's done, restart your PC and test pip --version again, if you see a version number you're good to go so you can run the batch file again and it should install.

Hi, thanks for this, but will this affect the 3.12 install? just wanted to make sure before changing anything.

pesado1 avatar Jul 19 '24 15:07 pesado1

Hi, thanks for this, but will this affect the 3.12 install? just wanted to make sure before changing anything.

If you have 3.12 installed on your system there are ways to install 3.10.6 without adding it to PATH and affecting your 3.12 install that is in PATH, or even just getting the 3.10.6 executable without installing it and pointing the program towards that. However, specifics depend on your system. I can help if you're running Linux (Basically just check my first response to this issue) but I'm not knowledgeable on how to do any of this on Windows sadly.

FiratUsta avatar Jul 19 '24 15:07 FiratUsta

Hi, thanks for this, but will this affect the 3.12 install? just wanted to make sure before changing anything.

If you have 3.12 installed on your system there are ways to install 3.10.6 without adding it to PATH and affecting your 3.12 install that is in PATH, or even just getting the 3.10.6 executable without installing it and pointing the program towards that. However, specifics depend on your system. I can help if you're running Linux (Basically just check my first response to this issue) but I'm not knowledgeable on how to do any of this on Windows sadly.

thanks again, i got both, so i guess the 3.12 install messed up the paths. have no ideia why.. since both have the paths

image

pesado1 avatar Jul 19 '24 15:07 pesado1

Can confirm on ARCH. Both when installed from AUR: aur/stable-diffusion-webui-git 1.9.4.r0.gfeee37d-2 (+0 0.00) (Installed: 1.9.4.r0.gfeee37d-3) and downloaded manually. I attach log. Seems like some kind of available and required torch version mismatch? diffusion.log

This is a separate issue from the original report. You are trying to run the script in a Python 3.12 environment, webui doesn't support that version, you need to install Python 3.10.6. If you don't want to downgrade your system python, just download the tarball of 3.10.6, make it and then replace

python_cmd="python3"

with

python_cmd="[PATH TO PYTHON3.10.6 EXECUTABLE]"

in webui.sh then run it and it should work.

I actually have 3.10 installed (AUR version already installed it as dependence), the WebUI worked like 2-3 weeks ago, this week it suddenly stopped working (a bit of tactical googling lead me to this „identical for non-expert” issue).

Adding: export python_cmd="python3.10" to shell script which I use to start webui (with preferred parameters and in separate virtual console with screen utility) partially solved the issue for me - now proper version of python was utilised. However, as while pip was installed system wide, it was not detected by python3.10. Running: python3.10 -m ensurepip fixed the final issue, webui runs again.

If AUR package maintainer sees this: Maybe some package modyfication is needed?

Thank you @pesado1 your answers to both me and arkeence were essential for me to figure this out. EDIT: Redraft to improve clarity.

Aleszp avatar Jul 20 '24 11:07 Aleszp

Can confirm on ARCH. Both when installed from AUR: aur/stable-diffusion-webui-git 1.9.4.r0.gfeee37d-2 (+0 0.00) (Installed: 1.9.4.r0.gfeee37d-3) and downloaded manually. I attach log. Seems like some kind of available and required torch version mismatch? diffusion.log

This is a separate issue from the original report. You are trying to run the script in a Python 3.12 environment, webui doesn't support that version, you need to install Python 3.10.6. If you don't want to downgrade your system python, just download the tarball of 3.10.6, make it and then replace

python_cmd="python3"

with

python_cmd="[PATH TO PYTHON3.10.6 EXECUTABLE]"

in webui.sh then run it and it should work.

I'm trying to fumble my way through this in an Arch DistroBox... I made the Python-3.10.6 tarball --configured into:

$HOME/LLMs/AUTOMATIC1111/Python-3.10.6/

And the edited webui.sh entry looks like this:

python_cmd="$HOME/LLMs/AUTOMATIC1111/Python-3.10.6/bin/python3.10"

But I can't seem to get the webui.sh to find it? It still throws me the same error of being in a 3.12 environment, even if I point towards the python3.10 executable or the python3 link.

Am I just too stupid to understand how to path towards an executable in Linux or what am I missing here? :(

Dark-Thoughts avatar Nov 04 '24 12:11 Dark-Thoughts

I'm trying to fumble my way through this in an Arch DistroBox... I made the Python-3.10.6 tarball --configured into:

$HOME/LLMs/AUTOMATIC1111/Python-3.10.6/

And the edited webui.sh entry looks like this:

python_cmd="$HOME/LLMs/AUTOMATIC1111/Python-3.10.6/bin/python3.10"

But I can't seem to get the webui.sh to find it? It still throws me the same error of being in a 3.12 environment, even if I point towards the python3.10 executable or the python3 link.

Am I just too stupid to understand how to path towards an executable in Linux or what am I missing here? :(

Been a while since I last messed around with this but I checked my shell script to see if I can help. My python_cmd line looks like this:

python_cmd="/home/[my username]/Python-3.10.6/python"

It's different than yours in two ways; firstly, instead of using the $HOME env var, the entire path is spelt out. Maybe try this? Secondly, my python executable is named just python instead of python3.10, but I'm not sure if I renamed that or was it always like that. Maybe check that, or rename your executable?

Again, it's been a while so I'm sorry if this is no help.

FiratUsta avatar Nov 04 '24 13:11 FiratUsta

Same result unfortunately. Not sure why your python executable is named differently. I used the tarball from the link on the main page: https://www.python.org/downloads/release/python-3106/ But I find the Linux install instructions generally very confusing. Tried writing python3.11 too, even though it says not to confuse python311 with 3.11.

Dark-Thoughts avatar Nov 04 '24 15:11 Dark-Thoughts

Unfortunately I'm clueless after this

FiratUsta avatar Nov 04 '24 19:11 FiratUsta

Check which pip is being used. You may need to make sure that it is the one installed in 3.10. Maybe try and create a fresh venv and install pip into that. In my case this fixed the issue.

flipswitchingmonkey avatar Mar 31 '25 00:03 flipswitchingmonkey