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

[Bug]: "Couldn't Install Torch" could not find torch issue

Open Friszion opened this issue 2 years ago • 18 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and checked the recent builds/commits

What happened?

Installing torch and torchvision Traceback (most recent call last): File "C:\Users\BENJIII\stable-diffusion-webui\launch.py", line 306, in prepare_environment() File "C:\Users\BENJIII\stable-diffusion-webui\launch.py", line 218, in prepare_environment run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch") File "C:\Users\BENJIII\stable-diffusion-webui\launch.py", line 64, in run raise RuntimeError(message) RuntimeError: Couldn't install torch. Command: "C:\Users\BENJIII\stable-diffusion-webui\venv\Scripts\python.exe" -m pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113 Error code: 1 stdout: Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu113

stderr: ERROR: Could not find a version that satisfies the requirement torch==1.12.1+cu113 (from versions: none) ERROR: No matching distribution found for torch==1.12.1+cu113

when clicking on webuiuser folder to run program

Steps to reproduce the problem

  1. download python
  2. download git
  3. download stable diffusion
  4. download model folder
  5. set folder to models location in C:\users folder 7.right click on webui-user, go to edit add in "git pull"
  6. fill in python section with folder location of python
  7. run webui

What should have happened?

the program should have ran and spat out a web address for me to go to

Commit where the problem happens

bd4587d2f5b70ed951d2c17f25a4622fc1cb31c2

What platforms do you use to access UI ?

Windows

What browsers do you use to access the UI ?

Microsoft Edge

Command Line Arguments

No response

Additional information, context and logs

No response

Friszion avatar Jan 10 '23 07:01 Friszion

What's your Python version? In case it's not 3.10.6, uninstall Python, Install 3.10.6 from here

ataa avatar Jan 10 '23 10:01 ataa

cant be a newer version?

jonicool97 avatar Jan 10 '23 15:01 jonicool97

I was getting the same error, uninstalled python and installed the correct version, now I'm getting an error 'no python at ....' the location where the newer version of python was installed. How do we correctly uninstall the wrong version of python and add the right one (there is no reference to the wrong version in the path variable)

markl181 avatar Jan 11 '23 00:01 markl181

I was getting the same error, uninstalled python and installed the correct version, now I'm getting an error 'no python at ....' the location where the newer version of python was installed. How do we correctly uninstall the wrong version of python and add the right one (there is no reference to the wrong version in the path variable)

That makes two of us....I'm getting that same error after thinking "If it's going to be a newer Python, it's going to be retro compatible...how foolish can I be?

rfariavitor avatar Jan 11 '23 01:01 rfariavitor

cannot be 3.11. Any version from 3.8 to 3.10 works. No need to be 3.10.6 as that's outdated

aliencaocao avatar Jan 11 '23 05:01 aliencaocao

I was getting the same error, uninstalled python and installed the correct version, now I'm getting an error 'no python at ....' the location where the newer version of python was installed. How do we correctly uninstall the wrong version of python and add the right one (there is no reference to the wrong version in the path variable)

That makes two of us....I'm getting that same error after thinking "If it's going to be a newer Python, it's going to be retro compatible...how foolish can I be?

After installing the correct version of python 3.10.x, my solution was to delete the 'venv' folder out of your stable-diffusion-webui-master' directory. then hit the bat again.

MobileDanceTeam avatar Jan 11 '23 09:01 MobileDanceTeam

I was getting the same error, uninstalled python and installed the correct version, now I'm getting an error 'no python at ....' the location where the newer version of python was installed. How do we correctly uninstall the wrong version of python and add the right one (there is no reference to the wrong version in the path variable)

That makes two of us....I'm getting that same error after thinking "If it's going to be a newer Python, it's going to be retro compatible...how foolish can I be?

After installing the correct version of python 3.10.x, my solution was to delete the 'venv' folder out of your stable-diffusion-webui-master' directory. then hit the bat again.

That worked for me. Thank you so much.

rfariavitor avatar Jan 11 '23 23:01 rfariavitor

The simplest solution seems to be:

  1. Disable Windows defender or any applicable virus software (temporarily)
  2. Run CMD and navigate to the folder where you installed Python 3.10.6
  3. Then type python -m ensurepip

Everything should now work as normal.

You may also have to turn off the app installer for all versions of python in the "Manage app execution aliases" window if running on Windows 10 or later.

Xenogene83 avatar Jan 17 '23 11:01 Xenogene83

This was a pain that took me days so I'll share what finally worked for me. As far as it went for me, the real issue was pip screwing up when downloading pytorch. No idea why, it just was. To do this fix, first make sure you are using Python 3.10.6; would be a waste of time to do it and get the wrong version that breaks it anyways.

  1. CD into your stable-diffusion-webui/venv/Scripts folder, it's all gonna go down here
  2. You'll need Wheel for this, so start with a python.exe -m pip install --upgrade pip setuptools wheel
  3. Download this file; it's the .whl file that your webui keeps trying to but never managing to get; if you don't wanna trust a random poster, you can easily look for it on pytorch's website. Just look for version 1.13.1, Instead of downloading it with pip install try to run it once, it'll show you the exact download link python is trying to use; you can just copy that and throw into your browser and voilá
  4. After downloading the wheel file, copy it's address in your system and go back to the prompt you had inside your Scripts folder
  5. Run python.exe -m pip install your/wheel/file/directory.whl

This will basically force pytorch down webui's throat, and the rest of the instalation should proceed as expected. Hope this helps!

PS.: If pytorch is not downloading for you on cmd, odds are it won't download on a regular browser downloader either (the download failed 3 times for me at the same point it broke down on the cmd) so I suggest using some sort of manager that keeps downloads from failing when connection is briefly lost; I used FDM and it worked first time PPS.: I am like, 99% sure that you'd need Wheel even without going this method, that is a .whl file you're downloading after all; why the webui script doesn't take this into account and install it is beyond me

mordtirith avatar Mar 22 '23 05:03 mordtirith

@mordtirith when running the installation of the wheel file i get the error: ERROR: torch-1.13.1+cu117-cp310-cp310-win_amd64.whl is not a supported wheel on this platform.

i use windows 11 if thats the problem

logicbreaks avatar Apr 07 '23 15:04 logicbreaks

are you on python 3.10?

aliencaocao avatar Apr 07 '23 16:04 aliencaocao

No, 3.11.2, oh yes i see my error

logicbreaks avatar Apr 08 '23 08:04 logicbreaks

Then thats the problem. The wheel is build for python 3.10

aliencaocao avatar Apr 08 '23 08:04 aliencaocao

If you run the stable diffusion with a different Python version, than what your system is using generally/ by default is set to use, you need to check the following "stable-diffusion-webui\venv\pyvenv.cfg" and set the home/executable/command variable to the python 3.10.6 installation. That will make the execution and torch installation work.

I had the same problem with Win, works just fine for now.

ManfredHam avatar Apr 10 '23 23:04 ManfredHam

If you're running Linux with multiple versions of Python, you can edit webui.sh to point to python3.10 (the parallel install name of 3.10 in my case) instead of python3 which may default to > Python 3.11

Delete the broken venv and then re-run webui.sh and then have another go

aidenbell avatar Apr 13 '23 14:04 aidenbell

If you're running Linux with multiple versions of Python, you can edit webui.sh to point to python3.10 (the parallel install name of 3.10 in my case) instead of python3 which may default to > Python 3.11

Delete the broken venv and then re-run webui.sh and then have another go

You save my day

DakerHub avatar Apr 21 '23 18:04 DakerHub

This was a pain that took me days so I'll share what finally worked for me. As far as it went for me, the real issue was pip screwing up when downloading pytorch. No idea why, it just was. To do this fix, first make sure you are using Python 3.10.6; would be a waste of time to do it and get the wrong version that breaks it anyways.

  1. CD into your stable-diffusion-webui/venv/Scripts folder, it's all gonna go down here
  2. You'll need Wheel for this, so start with a python.exe -m pip install --upgrade pip setuptools wheel
  3. Download this file; it's the .whl file that your webui keeps trying to but never managing to get; if you don't wanna trust a random poster, you can easily look for it on pytorch's website. Just look for version 1.13.1, Instead of downloading it with pip install try to run it once, it'll show you the exact download link python is trying to use; you can just copy that and throw into your browser and voilá
  4. After downloading the wheel file, copy it's address in your system and go back to the prompt you had inside your Scripts folder
  5. Run python.exe -m pip install your/wheel/file/directory.whl

This will basically force pytorch down webui's throat, and the rest of the instalation should proceed as expected. Hope this helps!

PS.: If pytorch is not downloading for you on cmd, odds are it won't download on a regular browser downloader either (the download failed 3 times for me at the same point it broke down on the cmd) so I suggest using some sort of manager that keeps downloads from failing when connection is briefly lost; I used FDM and it worked first time PPS.: I am like, 99% sure that you'd need Wheel even without going this method, that is a .whl file you're downloading after all; why the webui script doesn't take this into account and install it is beyond me

Been working on this issue for a while and I followed these steps, CMD tells me torch is installed. Wondering about the next step since running the webui-user.bat just starts downloading the file again, and eventually gives me the same error as before. How do I tell it that the file is already downloaded? or does this mean that I am having a different issue...

105000907 avatar May 04 '23 23:05 105000907

I renamed venv as BAD_venv and it seems to be working fine now. Thanks to whomever suggested venv as the culprit.

paulrus avatar Jun 21 '23 21:06 paulrus

This was a pain that took me days so I'll share what finally worked for me. As far as it went for me, the real issue was pip screwing up when downloading pytorch. No idea why, it just was. To do this fix, first make sure you are using Python 3.10.6; would be a waste of time to do it and get the wrong version that breaks it anyways.

  1. CD into your stable-diffusion-webui/venv/Scripts folder, it's all gonna go down here
  2. You'll need Wheel for this, so start with a python.exe -m pip install --upgrade pip setuptools wheel
  3. Download this file; it's the .whl file that your webui keeps trying to but never managing to get; if you don't wanna trust a random poster, you can easily look for it on pytorch's website. Just look for version 1.13.1, Instead of downloading it with pip install try to run it once, it'll show you the exact download link python is trying to use; you can just copy that and throw into your browser and voilá
  4. After downloading the wheel file, copy it's address in your system and go back to the prompt you had inside your Scripts folder
  5. Run python.exe -m pip install your/wheel/file/directory.whl

This will basically force pytorch down webui's throat, and the rest of the instalation should proceed as expected. Hope this helps! PS.: If pytorch is not downloading for you on cmd, odds are it won't download on a regular browser downloader either (the download failed 3 times for me at the same point it broke down on the cmd) so I suggest using some sort of manager that keeps downloads from failing when connection is briefly lost; I used FDM and it worked first time PPS.: I am like, 99% sure that you'd need Wheel even without going this method, that is a .whl file you're downloading after all; why the webui script doesn't take this into account and install it is beyond me

Been working on this issue for a while and I followed these steps, CMD tells me torch is installed. Wondering about the next step since running the webui-user.bat just starts downloading the file again, and eventually gives me the same error as before. How do I tell it that the file is already downloaded? or does this mean that I am having a different issue...

I had the same issue and resolved it by using the method posted by 105000907 but installing the version of the torch .whl file that webui-user.bat kept trying to install, in my case 2.0.1. The webui-user.bat install logs actually provide a direct link to the .whl file that it tries to install, so I copied that. Finally up and running.

THANK YOU to 105000907 for posting that solution.

shadowofthel1ght avatar Jun 25 '23 19:06 shadowofthel1ght

This was a pain that took me days so I'll share what finally worked for me. As far as it went for me, the real issue was pip screwing up when downloading pytorch. No idea why, it just was. To do this fix, first make sure you are using Python 3.10.6; would be a waste of time to do it and get the wrong version that breaks it anyways.

  1. CD into your stable-diffusion-webui/venv/Scripts folder, it's all gonna go down here
  2. You'll need Wheel for this, so start with a python.exe -m pip install --upgrade pip setuptools wheel
  3. Download this file; it's the .whl file that your webui keeps trying to but never managing to get; if you don't wanna trust a random poster, you can easily look for it on pytorch's website. Just look for version 1.13.1, Instead of downloading it with pip install try to run it once, it'll show you the exact download link python is trying to use; you can just copy that and throw into your browser and voilá
  4. After downloading the wheel file, copy it's address in your system and go back to the prompt you had inside your Scripts folder
  5. Run python.exe -m pip install your/wheel/file/directory.whl

This will basically force pytorch down webui's throat, and the rest of the instalation should proceed as expected. Hope this helps! PS.: If pytorch is not downloading for you on cmd, odds are it won't download on a regular browser downloader either (the download failed 3 times for me at the same point it broke down on the cmd) so I suggest using some sort of manager that keeps downloads from failing when connection is briefly lost; I used FDM and it worked first time PPS.: I am like, 99% sure that you'd need Wheel even without going this method, that is a .whl file you're downloading after all; why the webui script doesn't take this into account and install it is beyond me

Been working on this issue for a while and I followed these steps, CMD tells me torch is installed. Wondering about the next step since running the webui-user.bat just starts downloading the file again, and eventually gives me the same error as before. How do I tell it that the file is already downloaded? or does this mean that I am having a different issue...

I had the same issue and resolved it by using the method posted by 105000907 but installing the version of the torch .whl file that webui-user.bat kept trying to install, in my case 2.0.1. The webui-user.bat install logs actually provide a direct link to the .whl file that it tries to install, so I copied that. Finally up and running.

THANK YOU to 105000907 for posting that solution.

I did that, but still webui-user.bat tries to download torch itself...

ki11erful avatar Jul 03 '23 21:07 ki11erful

Closing as stale.

catboxanon avatar Aug 03 '23 17:08 catboxanon

https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/6592#issuecomment-1507025717 @aidenbell What is particular did you change? I changed line 47 python_cmd="python3" and the script would not run. "3.10.0 not installed" Thanks.

coffseducation avatar Oct 03 '23 08:10 coffseducation