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

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

Open
3 of 6 tasks
arkeence opened this issue Jul 15, 2024 · 9 comments
Open
3 of 6 tasks

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

arkeence opened this issue Jul 15, 2024 · 9 comments
Labels
bug-report Report of a bug, yet to be confirmed

Comments

@arkeence
Copy link

arkeence commented Jul 15, 2024

Checklist

  • The issue exists after disabling all extensions
  • 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
  • The issue exists in the current version of the webui
  • The issue has not been reported before recently
  • 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 arkeence added the bug-report Report of a bug, yet to be confirmed label Jul 15, 2024
@Aleszp
Copy link

Aleszp commented Jul 17, 2024

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

@pesado1
Copy link

pesado1 commented Jul 18, 2024

I'm having the same problem

@FiratUsta
Copy link

FiratUsta commented Jul 19, 2024

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.

@arkeence
Copy link
Author

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?

@FiratUsta
Copy link

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.

@pesado1
Copy link

pesado1 commented Jul 19, 2024

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.

@FiratUsta
Copy link

FiratUsta commented Jul 19, 2024

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.

@pesado1
Copy link

pesado1 commented Jul 19, 2024

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

@Aleszp
Copy link

Aleszp commented Jul 20, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-report Report of a bug, yet to be confirmed
Projects
None yet
Development

No branches or pull requests

4 participants