AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
136.37k stars 25.99k forks source link

[Bug]: Couldn't install torch #12073

Open RadFox34 opened 12 months ago

RadFox34 commented 12 months ago

Is there an existing issue for this?

What happened?

I've already attempted solutions like reinstalling python 3.10.6, deleting venv, doing both at the same time, manually installing torchvision via a .whl file, none of those work. Webui.bat still gives this error.

Steps to reproduce the problem

  1. Go to Webui.bat
  2. Press Open
  3. Unable to install torchvision

What should have happened?

Stable Diffusion completes the installation and starts as normal.

Version or Commit where the problem happens

1.4.0

What Python version are you running on ?

Python 3.10.x

What platforms do you use to access the UI ?

Windows

What device are you running WebUI on?

Nvidia GPUs (GTX 16 below)

Cross attention optimization

None

What browsers do you use to access the UI ?

Mozilla Firefox

Command Line Arguments

--lowvram

List of extensions

No

Console logs

venv "D:\AI\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.4.1
Commit hash: f865d3e11647dfd6c7b2cdf90dde24680e58acd8
Installing torch and torchvision
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu118
Collecting torch==2.0.1
ERROR: Exception:
Traceback (most recent call last):
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\cli\base_command.py", line 167, in exc_logging_wrapper
    status = run_func(*args)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\cli\req_command.py", line 247, in wrapper
    return func(self, options, args)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\commands\install.py", line 369, in run
    requirement_set = resolver.resolve(
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 92, in resolve
    result = self._result = resolver.resolve(
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 481, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 348, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 172, in _add_to_criteria
    if not criterion.candidates:
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\resolvelib\structs.py", line 151, in __bool__
    return bool(self._sequence)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 155, in __bool__
    return any(self)
  File "D:\AI\stable-diffusion-webui\venv\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 "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 47, in _iter_built
    candidate = func()
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 206, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 297, in __init__
    super().__init__(
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 162, in __init__
    self.dist = self._prepare()
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 231, in _prepare
    dist = self._prepare_distribution()
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 308, in _prepare_distribution
    return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\operations\prepare.py", line 438, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\operations\prepare.py", line 483, in _prepare_linked_requirement
    local_file = unpack_url(
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\operations\prepare.py", line 165, in unpack_url
    file = get_http_url(
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\operations\prepare.py", line 106, in get_http_url
    from_path, content_type = download(link, temp_dir.path)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\network\download.py", line 134, in __call__
    resp = _http_get_download(self._session, link)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\network\download.py", line 117, in _http_get_download
    resp = session.get(target_url, headers=HEADERS, stream=True)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\requests\sessions.py", line 600, in get
    return self.request("GET", url, **kwargs)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\network\session.py", line 518, in request
    return super().request(method, url, *args, **kwargs)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\requests\sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\requests\sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\cachecontrol\adapter.py", line 48, in send
    cached_response = self.controller.cached_request(request)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\cachecontrol\controller.py", line 155, in cached_request
    resp = self.serializer.loads(request, cache_data, body_file)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\cachecontrol\serialize.py", line 95, in loads
    return getattr(self, "_loads_v{}".format(ver))(request, data, body_file)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\cachecontrol\serialize.py", line 186, in _loads_v4
    cached = msgpack.loads(data, raw=False)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\msgpack\fallback.py", line 125, in unpackb
    ret = unpacker._unpack()
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\msgpack\fallback.py", line 590, in _unpack
    ret[key] = self._unpack(EX_CONSTRUCT)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\msgpack\fallback.py", line 590, in _unpack
    ret[key] = self._unpack(EX_CONSTRUCT)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\msgpack\fallback.py", line 544, in _unpack
    typ, n, obj = self._read_header()
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\msgpack\fallback.py", line 486, in _read_header
    obj = self._read(n)
  File "D:\AI\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\msgpack\fallback.py", line 403, in _read
    ret = self._buffer[i : i + n]
MemoryError

[notice] A new release of pip available: 22.2.1 -> 23.2.1
[notice] To update, run: D:\AI\stable-diffusion-webui\venv\Scripts\python.exe -m pip install --upgrade pip
Traceback (most recent call last):
  File "D:\AI\stable-diffusion-webui\launch.py", line 38, in <module>
    main()
  File "D:\AI\stable-diffusion-webui\launch.py", line 29, in main
    prepare_environment()
  File "D:\AI\stable-diffusion-webui\modules\launch_utils.py", line 265, in prepare_environment
    run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
  File "D:\AI\stable-diffusion-webui\modules\launch_utils.py", line 107, in run
    raise RuntimeError("\n".join(error_bits))
RuntimeError: Couldn't install torch.
Command: "D:\AI\stable-diffusion-webui\venv\Scripts\python.exe" -m pip install torch==2.0.1 torchvision==0.15.2 --extra-index-url https://download.pytorch.org/whl/cu118
Error code: 2
Press any key to continue . . .


### Additional information

_No response_
yykkxx commented 12 months ago

that is MemoryError You need more memory so that you can run it successfully

yykkxx commented 12 months ago

Download the whl file of pytorch need many memory,8gb is not enough

yykkxx commented 12 months ago

or you can set more Virtual memory

RadFox34 commented 12 months ago

Download the whl file of pytorch need many memory,8gb is not enough

I have 16gb memory and it was plenty to use this, but now it's an issue when attempting a reinstall. I also mentioned above that downloading the .whl of pytorch did not fix anything.

yykkxx commented 12 months ago

Maybe you can try use real python,not venv

yykkxx commented 12 months ago

run python launch.py

yykkxx commented 12 months ago

python launch.py --lowvram

RadFox34 commented 11 months ago

I tried that and it gave me this:

Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] Version: v1.4.1 Commit hash: f865d3e11647dfd6c7b2cdf90dde24680e58acd8 Traceback (most recent call last): File "D:\AI\stable-diffusion-webui\launch.py", line 38, in <module> main() File "D:\AI\stable-diffusion-webui\launch.py", line 29, in main prepare_environment() File "D:\AI\stable-diffusion-webui\modules\launch_utils.py", line 268, in prepare_environment raise RuntimeError( RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check

so I tried the arg and it did this instead

D:\AI\stable-diffusion-webui>python launch.py --lowvram --skip-torch-cuda-test
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: v1.4.1
Commit hash: f865d3e11647dfd6c7b2cdf90dde24680e58acd8
Installing requirements
Launching Web UI with arguments: --lowvram --skip-torch-cuda-test
No module 'xformers'. Proceeding without it.
Warning: caught exception 'Torch not compiled with CUDA enabled', memory monitor disabled
Loading weights [812cd9f9d9] from D:\AI\stable-diffusion-webui\models\Stable-diffusion\anythingV3_fp16.ckpt
Exception in thread Thread-17 (first_time_calculation):
Traceback (most recent call last):
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "D:\AI\stable-diffusion-webui\modules\devices.py", line 170, in first_time_calculation
    linear(x)
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "D:\AI\stable-diffusion-webui\extensions-builtin\Lora\lora.py", line 400, in lora_Linear_forward
    return torch.nn.Linear_forward_before_lora(self, input)
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\linear.py", line 114, in forward
    return F.linear(input, self.weight, self.bias)
RuntimeError: "addmm_impl_cpu_" not implemented for 'Half'
preload_extensions_git_metadata for 7 extensions took 0.00s
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 7.7s (import torch: 2.5s, import gradio: 1.2s, import ldm: 0.6s, other imports: 1.4s, load scripts: 1.3s, create ui: 0.4s, gradio launch: 0.1s).
Creating model from config: D:\AI\stable-diffusion-webui\configs\v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Applying attention optimization: InvokeAI... done.
Textual inversion embeddings loaded(0):
loading stable diffusion model: RuntimeError
Traceback (most recent call last):
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\threading.py", line 973, in _bootstrap
    self._bootstrap_inner()
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "D:\AI\stable-diffusion-webui\webui.py", line 306, in load_model
    shared.sd_model  # noqa: B018
  File "D:\AI\stable-diffusion-webui\modules\shared.py", line 726, in sd_model
    return modules.sd_models.model_data.get_sd_model()
  File "D:\AI\stable-diffusion-webui\modules\sd_models.py", line 422, in get_sd_model
    load_model()
  File "D:\AI\stable-diffusion-webui\modules\sd_models.py", line 510, in load_model
    sd_model.cond_stage_model_empty_prompt = sd_model.cond_stage_model([""])
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "D:\AI\stable-diffusion-webui\modules\sd_hijack_clip.py", line 229, in forward
    z = self.process_tokens(tokens, multipliers)
  File "D:\AI\stable-diffusion-webui\modules\sd_hijack_clip.py", line 254, in process_tokens
    z = self.encode_with_transformers(tokens)
  File "D:\AI\stable-diffusion-webui\modules\sd_hijack_clip.py", line 302, in encode_with_transformers
    outputs = self.wrapped.transformer(input_ids=tokens, output_hidden_states=-opts.CLIP_stop_at_last_layers)
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1538, in _call_impl
    result = forward_call(*args, **kwargs)
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\clip\modeling_clip.py", line 811, in forward
    return self.text_model(
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\clip\modeling_clip.py", line 721, in forward
    encoder_outputs = self.encoder(
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\clip\modeling_clip.py", line 650, in forward
    layer_outputs = encoder_layer(
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\clip\modeling_clip.py", line 378, in forward
    hidden_states = self.layer_norm1(hidden_states)
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\normalization.py", line 190, in forward
    return F.layer_norm(
  File "C:\Users\ninjj\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\functional.py", line 2515, in layer_norm
    return torch.layer_norm(input, normalized_shape, weight, bias, eps, torch.backends.cudnn.enabled)
RuntimeError: "LayerNormKernelImpl" not implemented for 'Half'

Stable diffusion model failed to load
Galzk commented 11 months ago

@RadFox34 Here's how I got mine to run: python launch.py --lowvram --skip-torch-cuda-test --no-half A safe bet is to re-install all dependencies just to make sure you have a clean slate, I'm pulling on the same directory from a year ago