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

[Bug]: Extracted Loras throw a runtime error with new torch 2.0 update, native Loras are fine

Open Mozoloa opened this issue 1 year ago • 8 comments

Is there an existing issue for this?

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

What happened?

I have extracted Loras of some models with Kohya utilities and they worked perfectly well in the past, but since I started fresh with the recent commit : 72cd27a13587c9579942577e9e3880778be195f6 and it installed Torch 2.0 + CU118, they don't and throw and error :

RuntimeError: output with shape [256, 320, 1, 1] doesn't match the broadcast shape [256, 320, 3, 3]

Steps to reproduce the problem

  1. Go to txt2img
  2. Insert a Lora via the extra networks menu
  3. Click gen
  4. See this: RuntimeError: output with shape [256, 320, 1, 1] doesn't match the broadcast shape [256, 320, 3, 3]

What should have happened?

The lora should be loaded like it did before

Commit where the problem happens

72cd27a13587c9579942577e9e3880778be195f6

What platforms do you use to access the UI ?

Windows

What browsers do you use to access the UI ?

Google Chrome

Command Line Arguments

--ckpt-dir 'G:\AI\Models\Stable-diffusion\Checkpoints' --opt-sdp-attention --embeddings-dir 'G:\AI\Models\Stable-diffusion\Embeddings' --lora-dir 'G:\AI\Models\Stable-diffusion\Lora'

tried with --xformers as well instead of --opt-sdp-attention, no chance

List of extensions

ControlNet Infinite Image Browser

Console logs

Loading Lora G:\AI\Models\Stable-diffusion\Lora\People\Leo Justintrudeau.safetensors: RuntimeError 0/20 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "G:\AI\Image Gen\A1111\stable-diffusion-webui\extensions-builtin\Lora\lora.py", line 215, in load_loras
    lora = load_lora(name, lora_on_disk.filename)
  File "G:\AI\Image Gen\A1111\stable-diffusion-webui\extensions-builtin\Lora\lora.py", line 176, in load_lora
    module.weight.copy_(weight)
RuntimeError: output with shape [256, 320, 1, 1] doesn't match the broadcast shape [256, 320, 3, 3]

Additional information

Tried with python 3.10.6 and 3.10.9 all clean installs, no change

Mozoloa avatar May 01 '23 15:05 Mozoloa

I think I was getting this same issue but cannot quite recall what I did to resolve it.... I think I am now only using additional networks + LyCORIS, but not the LoCon extension..? Hopefully somebody else can clarify.

Oh, and do make sure you update all extensions and see if that helps.

evanjs avatar May 02 '23 14:05 evanjs

It was a clean install so everything was up to date afaik

Mozoloa avatar May 02 '23 14:05 Mozoloa

I have this issue too.

FLi79Za avatar May 02 '23 18:05 FLi79Za

+1

retronomi avatar May 03 '23 03:05 retronomi

Same here. Some Loras show RuntimeError, some AssertionError. Some do not throw an error, but the image is different than before or corrupted. I wonder if the issue is the built-in Lora extension? I tried to use another extension for loras as an workaround, unsuccesfully.

loading Lora C:\stable-diffusion-webui\models\Lora\Analog_Diffusion.safetensors: RuntimeError████████████████████████████████| 29/29 [00:03<00:00, 8.54it/s] Traceback (most recent call last): File "C:\stable-diffusion-webui\extensions\a1111-sd-webui-lycoris....\extensions-builtin/Lora\lora.py", line 215, in load_loras lora = load_lora(name, lora_on_disk.filename) File "C:\stable-diffusion-webui\extensions\a1111-sd-webui-lycoris....\extensions-builtin/Lora\lora.py", line 176, in load_lora module.weight.copy_(weight) RuntimeError: output with shape [128, 320, 1, 1] doesn't match the broadcast shape [128, 320, 3, 3]

quantumscience avatar May 03 '23 13:05 quantumscience

I found that if I disable lycoris extension, the error disappears from the console. You can use loras, although you will not render former images (to look the same). Also, some loras seem to have limited effect. Since I am exploring a workflow to sculpt the image with many various networks(I think I am not alone), it seems to be a big issue. So at the moment, try to disable the other network extensions.

quantumscience avatar May 04 '23 11:05 quantumscience

I found that if I disable lycoris extension, the error disappears from the console. You can use loras, although you will not render former images (to look the same). Also, some loras seem to have limited effect. Since I am exploring a workflow to sculpt the image with many various networks(I think I am not alone), it seems to be a big issue. So at the moment, try to disable the other network extensions.

I don't even have the lycoris extension 🤐

Mozoloa avatar May 04 '23 14:05 Mozoloa

+1 Same issue on my end. Haven't been able to find a fix yet. Some indications that this is related to Torch 2.0

markojak avatar May 07 '23 15:05 markojak

Should be fixed as part of https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/10089. Open a new issue if the problem persists.

catboxanon avatar Aug 11 '23 16:08 catboxanon