AUTOMATIC1111 / stable-diffusion-webui

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

[Bug]: RuntimeError: "LayerNormKernelImpl" not implemented for 'Half' #13519

Open GiveMeFox opened 11 months ago

GiveMeFox commented 11 months ago

Is there an existing issue for this?

What happened?

image

i found 8773 that talks about the same issue and from what i can see someone solved it by setting COMMANDLINE_ARGS="--skip-torch-cuda-test --precision full --no-half" but a weird thing happens when i try that

image

I doesn't even start and suggest adding --skip-torch-cuda-test to COMMANDLINE_ARGS but its already there am I doing something wrong? image

Steps to reproduce the problem

  1. run webui-user.bat
  2. click the Generate button

What should have happened?

I think I should be able to click generate and there shouldn't be any errors in the console

Sysinfo

sysinfo-2023-10-06-01-37.txt

What browsers do you use to access the UI ?

Other

Console logs

venv "C:\Users\PC\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.6.0
Commit hash: 5ef669de080814067961f28357256e8fe27544f4
Launching Web UI with arguments: --skip-torch-cuda-test
no module 'xformers'. Processing without...
no module 'xformers'. Processing without...
No module 'xformers'. Proceeding without it.
Warning: caught exception 'Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx', memory monitor disabled
Loading weights [6ce0161689] from C:\Users\PC\stable-diffusion-webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Creating model from config: C:\Users\PC\stable-diffusion-webui\configs\v1-inference.yaml
Startup time: 5.9s (prepare environment: 0.2s, import torch: 2.3s, import gradio: 0.6s, setup paths: 0.6s, initialize shared: 0.3s, other imports: 0.4s, load scripts: 0.7s, create ui: 0.4s, gradio launch: 0.3s).
Applying attention optimization: InvokeAI... done.
loading stable diffusion model: RuntimeError
Traceback (most recent call last):
  File "C:\Users\PC\.pyenv\pyenv-win\versions\3.10.6\lib\threading.py", line 973, in _bootstrap
    self._bootstrap_inner()
  File "C:\Users\PC\.pyenv\pyenv-win\versions\3.10.6\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Users\PC\.pyenv\pyenv-win\versions\3.10.6\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\PC\stable-diffusion-webui\modules\initialize.py", line 147, in load_model
    shared.sd_model  # noqa: B018
  File "C:\Users\PC\stable-diffusion-webui\modules\shared_items.py", line 110, in sd_model
    return modules.sd_models.model_data.get_sd_model()
  File "C:\Users\PC\stable-diffusion-webui\modules\sd_models.py", line 499, in get_sd_model
    load_model()
  File "C:\Users\PC\stable-diffusion-webui\modules\sd_models.py", line 649, in load_model
    sd_model.cond_stage_model_empty_prompt = get_empty_cond(sd_model)
  File "C:\Users\PC\stable-diffusion-webui\modules\sd_models.py", line 537, in get_empty_cond
    return sd_model.cond_stage_model([""])
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Users\PC\stable-diffusion-webui\modules\sd_hijack_clip.py", line 234, in forward
    z = self.process_tokens(tokens, multipliers)
  File "C:\Users\PC\stable-diffusion-webui\modules\sd_hijack_clip.py", line 273, in process_tokens
    z = self.encode_with_transformers(tokens)
  File "C:\Users\PC\stable-diffusion-webui\modules\sd_hijack_clip.py", line 326, in encode_with_transformers
    outputs = self.wrapped.transformer(input_ids=tokens, output_hidden_states=-opts.CLIP_stop_at_last_layers)
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 822, in forward
    return self.text_model(
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 740, in forward
    encoder_outputs = self.encoder(
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 654, in forward
    layer_outputs = encoder_layer(
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 382, in forward
    hidden_states = self.layer_norm1(hidden_states)
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Users\PC\stable-diffusion-webui\extensions-builtin\Lora\networks.py", line 474, in network_LayerNorm_forward
    return originals.LayerNorm_forward(self, input)
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\normalization.py", line 190, in forward
    return F.layer_norm(
  File "C:\Users\PC\stable-diffusion-webui\venv\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
Traceback (most recent call last):
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1431, in process_api
    result = await self.call_function(
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1103, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
Exception in thread Thread-16 (load_model):
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
Traceback (most recent call last):
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\gradio\utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "C:\Users\PC\.pyenv\pyenv-win\versions\3.10.6\lib\threading.py", line 1016, in _bootstrap_inner
  File "C:\Users\PC\stable-diffusion-webui\modules\ui_extra_networks.py", line 392, in pages_html
    return refresh()
    self.run()
  File "C:\Users\PC\stable-diffusion-webui\modules\ui_extra_networks.py", line 398, in refresh
    pg.refresh()
  File "C:\Users\PC\.pyenv\pyenv-win\versions\3.10.6\lib\threading.py", line 953, in run
  File "C:\Users\PC\stable-diffusion-webui\modules\ui_extra_networks_textual_inversion.py", line 13, in refresh
    sd_hijack.model_hijack.embedding_db.load_textual_inversion_embeddings(force_reload=True)
    self._target(*self._args, **self._kwargs)
  File "C:\Users\PC\stable-diffusion-webui\modules\textual_inversion\textual_inversion.py", line 255, in load_textual_inversion_embeddings
    self.expected_shape = self.get_expected_shape()
  File "C:\Users\PC\stable-diffusion-webui\modules\initialize.py", line 153, in load_model
  File "C:\Users\PC\stable-diffusion-webui\modules\textual_inversion\textual_inversion.py", line 154, in get_expected_shape
    vec = shared.sd_model.cond_stage_model.encode_embedding_init_text(",", 1)
    devices.first_time_calculation()
AttributeError: 'NoneType' object has no attribute 'cond_stage_model'
  File "C:\Users\PC\stable-diffusion-webui\modules\devices.py", line 148, in first_time_calculation
    linear(x)
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
Traceback (most recent call last):
    return forward_call(*args, **kwargs)
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\Users\PC\stable-diffusion-webui\extensions-builtin\Lora\networks.py", line 429, in network_Linear_forward
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1431, in process_api
    result = await self.call_function(
    return originals.Linear_forward(self, input)
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1103, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\linear.py", line 114, in forward
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
    return F.linear(input, self.weight, self.bias)
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
RuntimeError: "addmm_impl_cpu_" not implemented for 'Half'
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\gradio\utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "C:\Users\PC\stable-diffusion-webui\modules\ui_extra_networks.py", line 392, in pages_html
    return refresh()
  File "C:\Users\PC\stable-diffusion-webui\modules\ui_extra_networks.py", line 398, in refresh
    pg.refresh()
  File "C:\Users\PC\stable-diffusion-webui\modules\ui_extra_networks_textual_inversion.py", line 13, in refresh
    sd_hijack.model_hijack.embedding_db.load_textual_inversion_embeddings(force_reload=True)
  File "C:\Users\PC\stable-diffusion-webui\modules\textual_inversion\textual_inversion.py", line 255, in load_textual_inversion_embeddings
    self.expected_shape = self.get_expected_shape()
  File "C:\Users\PC\stable-diffusion-webui\modules\textual_inversion\textual_inversion.py", line 154, in get_expected_shape
    vec = shared.sd_model.cond_stage_model.encode_embedding_init_text(",", 1)
AttributeError: 'NoneType' object has no attribute 'cond_stage_model'
Using already loaded model v1-5-pruned-emaonly.safetensors [6ce0161689]: done in 0.0s
*** Error completing request
*** Arguments: ('task(fg6fqt8y87a19hu)', '', '', [], 20, 'DPM++ 2M Karras', 1, 1, 7, 512, 512, False, 0.7, 2, 'Latent', 0, 0, 0, 'Use same checkpoint', 'Use same sampler', '', '', [], <gradio.routes.Request object at 0x0000019201A61B70>, 0, False, '', 0.8, -1, False, -1, 0, 0, 0, False, False, 'positive', 'comma', 0, False, False, '', 1, '', [], 0, '', [], 0, '', [], True, False, False, False, 0, False) {}
    Traceback (most recent call last):
      File "C:\Users\PC\stable-diffusion-webui\modules\call_queue.py", line 57, in f
        res = list(func(*args, **kwargs))
      File "C:\Users\PC\stable-diffusion-webui\modules\call_queue.py", line 36, in f
        res = func(*args, **kwargs)
      File "C:\Users\PC\stable-diffusion-webui\modules\txt2img.py", line 55, in txt2img
        processed = processing.process_images(p)
      File "C:\Users\PC\stable-diffusion-webui\modules\processing.py", line 732, in process_images
        res = process_images_inner(p)
      File "C:\Users\PC\stable-diffusion-webui\modules\processing.py", line 856, in process_images_inner
        p.setup_conds()
      File "C:\Users\PC\stable-diffusion-webui\modules\processing.py", line 1309, in setup_conds
        super().setup_conds()
      File "C:\Users\PC\stable-diffusion-webui\modules\processing.py", line 469, in setup_conds
        self.uc = self.get_conds_with_caching(prompt_parser.get_learned_conditioning, negative_prompts, total_steps, [self.cached_uc], self.extra_network_data)
      File "C:\Users\PC\stable-diffusion-webui\modules\processing.py", line 455, in get_conds_with_caching
        cache[1] = function(shared.sd_model, required_prompts, steps, hires_steps, shared.opts.use_old_scheduling)
      File "C:\Users\PC\stable-diffusion-webui\modules\prompt_parser.py", line 189, in get_learned_conditioning
        conds = model.get_learned_conditioning(texts)
      File "C:\Users\PC\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\models\diffusion\ddpm.py", line 669, in get_learned_conditioning
        c = self.cond_stage_model(c)
      File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "C:\Users\PC\stable-diffusion-webui\modules\sd_hijack_clip.py", line 234, in forward
        z = self.process_tokens(tokens, multipliers)
      File "C:\Users\PC\stable-diffusion-webui\modules\sd_hijack_clip.py", line 273, in process_tokens
        z = self.encode_with_transformers(tokens)
      File "C:\Users\PC\stable-diffusion-webui\modules\sd_hijack_clip.py", line 326, in encode_with_transformers
        outputs = self.wrapped.transformer(input_ids=tokens, output_hidden_states=-opts.CLIP_stop_at_last_layers)
      File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 822, in forward
        return self.text_model(
      File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 740, in forward
        encoder_outputs = self.encoder(
      File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 654, in forward
        layer_outputs = encoder_layer(
      File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 382, in forward
        hidden_states = self.layer_norm1(hidden_states)
      File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "C:\Users\PC\stable-diffusion-webui\extensions-builtin\Lora\networks.py", line 474, in network_LayerNorm_forward
        return originals.LayerNorm_forward(self, input)
      File "C:\Users\PC\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\normalization.py", line 190, in forward
        return F.layer_norm(
      File "C:\Users\PC\stable-diffusion-webui\venv\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'

---

Additional information

No response

georgeokelly commented 9 months ago

Encounter this issue on Mac (with intel core), too. It seems the setting '--no-half' is not passed to Python modules correctly. A WAR is configure it in Python modules manually.

jaminW55 commented 9 months ago

I am now getting this issue on AMD. I added the same arguments as OP, and it does not seem to fix the issue for me. Notably, it was working fine last night.

 ᐉ stable-diffusion-web-ui-server --skip-torch-cuda-test --precision full --no-half

PC SPECS GPU: AMD 7900 XTX OS: Arch Linux; Install AUR Repository

aur/stable-diffusion-web-ui-git v1.6.0.r2.4afaaf8a-1 (+2 1.67) (Installed: v1.6.1.r0.4afaaf8a-1)
    Stable Diffusion Web UI (AUTOMATIC1111)
Manamama commented 8 months ago

CPU based Linux, below, it works.

This does the trick for me, as the args are passed on to the launch.py etc. files: bash webui.sh --skip-torch-cuda-test --no-half

FYI, I have had to manually install pip install xformers though.

Ref.


Central Processing Unit: Intel i5-8265U (8) @ 3.9GHz


Operating System: Ubuntu 22.04.3 LTS x86_64 Kernel: 6.2.0-39-generic Shell: /bin/bash 5.1.16 Python: 3.10.12