Repository: stable-diffusion-webui
Issue: [Bug]: TimeoutError/error code: 2/Couldn't install torch
Labels: bug-report

### Checklist

- [X] The issue exists after disabling all extensions
- [X] The issue exists on a clean installation of webui
- [X] 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
- [ ] The issue has been reported before but has not been fixed yet

### What happened?

when downloading it stops at 2.1/2.5 GB and gives the same error

### Steps to reproduce the problem

1. click webui.bat
2. wait till 2.1/2.5 GB is downloaded
3. Errors happen

### What should have happened?

it should download normally

### What browsers do you use to access the UI ?

_No response_

### Sysinfo

not there yet

### Console logs

```Shell
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: v1.9.0
Commit hash: adadb4e3c7382bf3e4f7519126cd6c70f4f8557b
Installing torch and torchvision
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu121
Collecting torch==2.1.2
  Downloading https://download.pytorch.org/whl/cu121/torch-2.1.2%2Bcu121-cp310-cp310-win_amd64.whl (2473.9 MB)
     ---------------------------------- ----- 2.1/2.5 GB 930.0 kB/s eta 0:05:50
ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 438, in _error_catcher
    yield
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 561, in read
    data = self._fp_read(amt) if not fp_closed else b""
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 527, in _fp_read
    return self._fp.read(amt) if amt is not None else self._fp.read()
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 98, in read
    data: bytes = self.__fp.read(amt)
  File "http\client.py", line 465, in read
  File "socket.py", line 705, in readinto
  File "ssl.py", line 1274, in recv_into
  File "ssl.py", line 1130, in read
TimeoutError: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\cli\base_command.py", line 180, in exc_logging_wrapper
    status = run_func(*args)
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\cli\req_command.py", line 245, in wrapper
    return func(self, options, args)
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\commands\install.py", line 377, in run
    requirement_set = resolver.resolve(
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 95, in resolve
    result = self._result = resolver.resolve(
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 397, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 173, in _add_to_criteria
    if not criterion.candidates:
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_vendor\resolvelib\structs.py", line 156, in __bool__
    return bool(self._sequence)
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 155, in __bool__
    return any(self)
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 143, in <genexpr>
    return (c for c in iterator if id(c) not in self._incompatible_ids)
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 47, in _iter_built
    candidate = func()
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 182, in _make_candidate_from_link
    base: Optional[BaseCandidate] = self._make_base_candidate_from_link(
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 228, in _make_base_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 290, in __init__
    super().__init__(
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 156, in __init__
    self.dist = self._prepare()
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 222, in _prepare
    dist = self._prepare_distribution()
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 301, in _prepare_distribution
    return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\operations\prepare.py", line 525, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\operations\prepare.py", line 596, in _prepare_linked_requirement
    local_file = unpack_url(
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\operations\prepare.py", line 168, in unpack_url
    file = get_http_url(
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\operations\prepare.py", line 109, in get_http_url
    from_path, content_type = download(link, temp_dir.path)
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\network\download.py", line 147, in __call__
    for chunk in chunks:
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\cli\progress_bars.py", line 53, in _rich_progress_bar
    for chunk in iterable:
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_internal\network\utils.py", line 63, in response_chunks
    for chunk in response.raw.stream(
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 622, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 560, in read
    with self._error_catcher():
  File "contextlib.py", line 153, in __exit__
  File "C:\Users\User\Desktop\stabe diffiusion\system\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 443, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='download.pytorch.org', port=443): Read timed out.
Traceback (most recent call last):
  File "C:\Users\User\Desktop\stabe diffiusion\webui\launch.py", line 48, in <module>
    main()
  File "C:\Users\User\Desktop\stabe diffiusion\webui\launch.py", line 39, in main
    prepare_environment()
  File "C:\Users\User\Desktop\stabe diffiusion\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\User\Desktop\stabe diffiusion\webui\modules\launch_utils.py", line 115, in run
    raise RuntimeError("\n".join(error_bits))
RuntimeError: Couldn't install torch.
Command: "C:\Users\User\Desktop\stabe diffiusion\system\python\python.exe" -m pip install torch==2.1.2 torchvision==0.16.2 --extra-index-url https://download.pytorch.org/whl/cu121
Error code: 2
Press any key to continue . . .
```


### Additional information

I have a good PC with 64 GB RAM and good internet, it downloads to 2.1 GB in about half an hour. The same problem happened to me a few years back but then I just gave up.