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

Unable to launch the Webui.bat - Unable to install torch

Open TheMindExpansionNetwork opened this issue 2 years ago • 12 comments

Describe the bug Hello figured to see if you all could help me out if not just bring it to the bug table for squash thank you for this tool.

Anyways I keep getting this error only when I attempt to open batt says attempting to download torch for a bit then error.

To Reproduce Steps to reproduce the behavior:

  1. go to command
    1. find the folder
  2. open CMD
  3. drag and drop the bat file to ensure its correct
  4. says installing torch
  5. failed error below.
  6. H:\AI\Atomicfusion\stable-diffusion-webui>H:\AI\Atomicfusion\stable-diffusion-webui\webui.bat Python 3.10.6 venv "H:\AI\Atomicfusion\stable-diffusion-webui\venv\Scripts\Python.exe" 45e8fa0e07db0fe04f91fef070a02925a40c8354 Installing torch... Failed to install torch

exit code: 2

stdout: Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu113 Collecting torch==1.12.1+cu113 Using cached https://download.pytorch.org/whl/cu113/torch-1.12.1%2Bcu113-cp310-cp310-win_amd64.whl (2143.8 MB) Requirement already satisfied: typing-extensions in h:\ai\atomicfusion\stable-diffusion-webui\venv\lib\site-packages (from torch==1.12.1+cu113) (4.3.0) Installing collected packages: torch

stderr: ERROR: Exception: Traceback (most recent call last): File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\cli\base_command.py", line 167, in exc_logging_wrapper status = run_func(*args) File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\cli\req_command.py", line 247, in wrapper return func(self, options, args) File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\commands\install.py", line 461, in run installed = install_given_reqs( File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\req_init_.py", line 73, in install_given_reqs requirement.install( File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\req\req_install.py", line 790, in install install_wheel( File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\operations\install\wheel.py", line 727, in install_wheel _install_wheel( File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\operations\install\wheel.py", line 587, in _install_wheel file.save() File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\operations\install\wheel.py", line 388, in save shutil.copyfileobj(f, dest) File "C:\Users\WeThe\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 195, in copyfileobj buf = fsrc_read(length) File "C:\Users\WeThe\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 925, in read data = self._read1(n) File "C:\Users\WeThe\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 1015, in _read1 self._update_crc(data) File "C:\Users\WeThe\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 943, in _update_crc raise BadZipFile("Bad CRC-32 for file %r" % self.name) zipfile.BadZipFile: Bad CRC-32 for file 'torch/lib/cublas64_11.dll'

[notice] A new release of pip available: 22.2.1 -> 22.2.2 [notice] To update, run: H:\AI\Atomicfusion\stable-diffusion-webui\venv\Scripts\python.exe -m pip install --upgrade pip

Launch unsuccessful. Exiting. Press any key to continue . . .

Expected behavior Should launch into the diffusion.

Screenshots image

Desktop (please complete the following information): Desktop/python

Additional context Please let me know whats going on want to inpaint.

TheMindExpansionNetwork avatar Sep 12 '22 18:09 TheMindExpansionNetwork

Same issues when I open webui

Requirement already satisfied: torch in c:\users\wethe\appdata\local\programs\python\python310\lib\site-packages (1.12.1) Requirement already satisfied: typing-extensions in c:\users\wethe\appdata\local\programs\python\python310\lib\site-packages (from torch) (4.3.0)

Not sure what is going on when I open says installing and just will error to this.

Python 3.10.6 venv "H:\AI\Atomicfusion\stable-diffusion-webui\venv\Scripts\Python.exe" c249bbb4d41ecfb43cf4ba43f23a4c8b08d8c56e Installing torch... Failed to install torch

exit code: 2

stdout: Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu113 Collecting torch==1.12.1+cu113 Using cached https://download.pytorch.org/whl/cu113/torch-1.12.1%2Bcu113-cp310-cp310-win_amd64.whl (2143.8 MB) Requirement already satisfied: typing-extensions in h:\ai\atomicfusion\stable-diffusion-webui\venv\lib\site-packages (from torch==1.12.1+cu113) (4.3.0) Installing collected packages: torch

stderr: ERROR: Exception: Traceback (most recent call last): File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\cli\base_command.py", line 167, in exc_logging_wrapper status = run_func(*args) File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\cli\req_command.py", line 247, in wrapper return func(self, options, args) File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\commands\install.py", line 461, in run installed = install_given_reqs( File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\req_init_.py", line 73, in install_given_reqs requirement.install( File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\req\req_install.py", line 790, in install install_wheel( File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\operations\install\wheel.py", line 727, in install_wheel _install_wheel( File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\operations\install\wheel.py", line 587, in _install_wheel file.save() File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\operations\install\wheel.py", line 388, in save shutil.copyfileobj(f, dest) File "C:\Users\WeThe\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 195, in copyfileobj buf = fsrc_read(length) File "C:\Users\WeThe\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 925, in read data = self._read1(n) File "C:\Users\WeThe\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 1015, in _read1 self._update_crc(data) File "C:\Users\WeThe\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 943, in _update_crc raise BadZipFile("Bad CRC-32 for file %r" % self.name) zipfile.BadZipFile: Bad CRC-32 for file 'torch/lib/cublas64_11.dll'

Launch unsuccessful. Exiting. Press any key to continue . . .

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows

From: @.> Sent: Monday, September 12, 2022 12:15 PM To: @.> Cc: @.>; @.> Subject: Re: [AUTOMATIC1111/stable-diffusion-webui] Unable to launch the Webui.bat - Unable to install torch (Issue #352)

  1. Go to command
  2. Write "pip install torch"

What happens?

— Reply to this email directly, view it on GitHubhttps://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/352#issuecomment-1244201000, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASNQBV2SZ7IA3BVMGF2HRF3V556MZANCNFSM6AAAAAAQKXKAOY. You are receiving this because you authored the thread.Message ID: @.***>

TheMindExpansionNetwork avatar Sep 12 '22 19:09 TheMindExpansionNetwork

try "pip install --force-reinstall --no-cache-dir torch"

jaykup1 avatar Sep 12 '22 19:09 jaykup1

https://download.pytorch.org/whl/cu113/torch-1.12.1%2Bcu113-cp310-cp310-win_amd64.whl

This file is corrupted somewhere on your machine and python keeps trying to reinstall torch it. Find and remove it. Comment above might also help.

AUTOMATIC1111 avatar Sep 12 '22 20:09 AUTOMATIC1111

Thank you for the reply.

Got this issue

Python 3.10.6 venv "H:\AI\Atomicfusion\stable-diffusion-webui\venv\Scripts\Python.exe" c249bbb4d41ecfb43cf4ba43f23a4c8b08d8c56e Installing torch... Failed to install torch

exit code: 2

stdout: Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu113 Collecting torch==1.12.1+cu113 Using cached https://download.pytorch.org/whl/cu113/torch-1.12.1%2Bcu113-cp310-cp310-win_amd64.whl (2143.8 MB) Requirement already satisfied: typing-extensions in h:\ai\atomicfusion\stable-diffusion-webui\venv\lib\site-packages (from torch==1.12.1+cu113) (4.3.0) Installing collected packages: torch

stderr: ERROR: Exception: Traceback (most recent call last): File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\cli\base_command.py", line 167, in exc_logging_wrapper status = run_func(*args) File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\cli\req_command.py", line 247, in wrapper return func(self, options, args) File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\commands\install.py", line 461, in run installed = install_given_reqs( File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\req_init_.py", line 73, in install_given_reqs requirement.install( File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\req\req_install.py", line 790, in install install_wheel( File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\operations\install\wheel.py", line 727, in install_wheel _install_wheel( File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\operations\install\wheel.py", line 587, in _install_wheel file.save() File "H:\AI\Atomicfusion\stable-diffusion-webui\venv\lib\site-packages\pip_internal\operations\install\wheel.py", line 388, in save shutil.copyfileobj(f, dest) File "C:\Users\WeThe\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 195, in copyfileobj buf = fsrc_read(length) File "C:\Users\WeThe\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 925, in read data = self._read1(n) File "C:\Users\WeThe\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 1015, in _read1 self._update_crc(data) File "C:\Users\WeThe\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 943, in _update_crc raise BadZipFile("Bad CRC-32 for file %r" % self.name) zipfile.BadZipFile: Bad CRC-32 for file 'torch/lib/cublas64_11.dll'

Launch unsuccessful. Exiting. Press any key to continue . . .

Not sure I searched for file delited it all.

Do you know where it should go manually.

just weird with torch.

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows

From: @.> Sent: Monday, September 12, 2022 1:48 PM To: @.> Cc: @.>; @.> Subject: Re: [AUTOMATIC1111/stable-diffusion-webui] Unable to launch the Webui.bat - Unable to install torch (Issue #352)

https://download.pytorch.org/whl/cu113/torch-1.12.1%2Bcu113-cp310-cp310-win_amd64.whl

This file is corrupted somewhere on your machine and python keeps trying to reinstall torch it. Find and remove it. Comment above might also help.

— Reply to this email directly, view it on GitHubhttps://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/352#issuecomment-1244443681, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASNQBVZKLUEA4RYCQ4RVLDDV56JKDANCNFSM6AAAAAAQKXKAOY. You are receiving this because you authored the thread.Message ID: @.***>

TheMindExpansionNetwork avatar Sep 12 '22 22:09 TheMindExpansionNetwork

I had the same issue but on Linux. The problem is with the torch install command in launch.py.

The fix was to wait until webui.sh (I think it's webui.py for you) has cloned the stable-diffusion-webui repo then go into the stable-diffusion-webui folder it created and edit the launch.py file line 14 to the following: torch_command = os.environ.get('TORCH_COMMAND', "pip install torch --extra-index-url https://download.pytorch.org/whl/cu116")

Then run webui.py again and the torch install should work without errors.

stoatmagoats avatar Sep 16 '22 05:09 stoatmagoats

Does anyone know how long 'installing torch' supposed to take? it has been 20 mins and still downloading something(appears in the network traffic).

tahaygun avatar Sep 16 '22 07:09 tahaygun

Hey I'm having the same problem:

Traceback (most recent call last): File "C:\stable-diffusion-webui-master\stable-diffusion-webui-master\launch.py", line 96, in run(f'"{python}" -m {torch_command}', "Installing torch", "Couldn't install torch") File "C:\stable-diffusion-webui-master\stable-diffusion-webui-master\launch.py", line 44, in run raise RuntimeError(message) RuntimeError: Couldn't install torch. Command: "C:\stable-diffusion-webui-master\stable-diffusion-webui-master\venv\Scripts\python.exe" -m pip install torch --extra-index-url https://download.pytorch.org/whl/cu116 Error code: 1 stdout: Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu116 Collecting torch Downloading https://download.pytorch.org/whl/cu116/torch-1.12.1%2Bcu116-cp310-cp310-win_amd64.whl (2388.4 MB) ---- 0.2/2.4 GB 9.1 MB/s eta 0:03:56

stderr: ERROR: Wheel 'torch' located at C:\Users\i\AppData\Local\Temp\pip-unpack-oi2nqngt\torch-1.12.1+cu116-cp310-cp310-win_amd64.whl is invalid.

I changed the download link as suggested above and I still get the error. I also tried manually downloading pytorch and placing it in the Temp folder, but the batch creates a different folder name each time.

Any more suggestions?

EDIT: I guess what I'm asking is where would I manually put the torch file in the stable-diffusion-ui-master folder...

colossalsthegame avatar Sep 19 '22 00:09 colossalsthegame

I'm having the same problem, it gets to 'Installing torch' and then just hangs. When I ctrl+ced to copy that it stopped trying install torch and went on to the next step , which it failed. I noticed that failed step mentioned not being able to find git, which would make sense because i have gitbash and its not in my path.

I'm going to try adding git to my path and reinstalling torch through the .bat file.

Update: Making sure git was in the path worked! I thought git was only needed for downloading the repo in the first place, hence not making sure it was in the path.

jadedResearcher avatar Sep 20 '22 02:09 jadedResearcher

I'm not good at English, so sorry if I misunderstood what you meant.

After removing "venv" and "temp" and trying "webui-user.bat" multiple times, I experienced both successful and unsuccessful torch installations. However, there was no visible difference in the execution environment, and we could not determine the cause.

However, even in the case of failure, I did not use pip, but manually downloaded torch, extracted whl, copied it to "venv\Lib\site-packages", and then executed "webui-user.bat" to confirm normal startup.

I would be happy if it is useful for those who want to run it for the time being.

OS windows 11

iPyon777 avatar Oct 19 '22 17:10 iPyon777

I once had fix where you take two certain files from the webUI directory and paste it in my Python's DLL folder. I forgot what were the two files.

Chrommanito avatar Jan 08 '23 08:01 Chrommanito

~\AppData\Local\pip\cache

Delete the files in here and issue will be resolved noting for people that need help

TheMindExpansionNetwork avatar Jan 11 '23 04:01 TheMindExpansionNetwork

after reading the scripts and other's comment on manual installlation, i fixed this by commenting out line 283-284 in launch.py:

# if reinstall_torch or not is_installed("torch") or not is_installed("torchvision"):
#     run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)

and creating a virtual environment myself, then manually downloading & locally installing the correct wheel the url in the torch command (https://download.pytorch.org/whl/cu117). i looked at the error message for the name of the correct wheel.

i still don't understand the exact cause of this error though. please let me know.

pandahop avatar Mar 15 '23 16:03 pandahop

this is an old issue which is fixed and no longer seems relevant, if this issue is related to future issues, please refer to this previous one.

ClashSAN avatar May 01 '23 19:05 ClashSAN

~\AppData\Local\pip\cache

Delete the files in here and issue will be resolved noting for people that need help

This fixed it for me, thanks a bunch!

Ivar360 avatar Mar 09 '24 19:03 Ivar360