Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Conflict with optimization padding cond: "RuntimeError: Sizes of tensors must match except in dimension 1" #25

Open
SLAPaper opened this issue Aug 6, 2023 · 3 comments

Comments

@SLAPaper
Copy link

SLAPaper commented Aug 6, 2023

Generating image of 800*1280, batch size 1, and getting this error:

    Traceback (most recent call last):
      File "C:\Users\SLAPaper\workspace\stable-diffusion-webui\modules\call_queue.py", line 58, in f
        res = list(func(*args, **kwargs))
      File "C:\Users\SLAPaper\workspace\stable-diffusion-webui\modules\call_queue.py", line 37, in f
        res = func(*args, **kwargs)
      File "C:\Users\SLAPaper\workspace\stable-diffusion-webui\modules\txt2img.py", line 62, in txt2img
        processed = processing.process_images(p)
      File "C:\Users\SLAPaper\workspace\stable-diffusion-webui\modules\processing.py", line 677, in process_images
        res = process_images_inner(p)
      File "C:\Users\SLAPaper\workspace\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\batch_hijack.py", line 42, in processing_process_images_hijack
        return getattr(processing, '__controlnet_original_process_images_inner')(p, *args, **kwargs)
      File "C:\Users\SLAPaper\workspace\stable-diffusion-webui\modules\processing.py", line 794, in process_images_inner
        samples_ddim = p.sample(conditioning=p.c, unconditional_conditioning=p.uc, seeds=p.seeds, subseeds=p.subseeds, subseed_strength=p.subseed_strength, prompts=p.prompts)
      File "C:\Users\SLAPaper\workspace\stable-diffusion-webui\modules\processing.py", line 1054, in sample
        samples = self.sampler.sample(self, x, conditioning, unconditional_conditioning, image_conditioning=self.txt2img_image_conditioning(x))
      File "C:\Users\SLAPaper\workspace\stable-diffusion-webui\modules\sd_samplers_kdiffusion.py", line 498, in sample
        samples = self.launch_sampling(steps, lambda: self.func(self.model_wrap_cfg, x, extra_args={
      File "C:\Users\SLAPaper\workspace\stable-diffusion-webui\modules\sd_samplers_kdiffusion.py", line 337, in launch_sampling
        return func()
      File "C:\Users\SLAPaper\workspace\stable-diffusion-webui\modules\sd_samplers_kdiffusion.py", line 498, in <lambda>
        samples = self.launch_sampling(steps, lambda: self.func(self.model_wrap_cfg, x, extra_args={
      File "C:\Users\SLAPaper\scoop\apps\miniconda3\current\envs\sd_webui\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
        return func(*args, **kwargs)
      File "C:\Users\SLAPaper\workspace\stable-diffusion-webui\repositories\k-diffusion\k_diffusion\sampling.py", line 128, in sample_euler
        denoised = model(x, sigma_hat * s_in, **extra_args)
      File "C:\Users\SLAPaper\scoop\apps\miniconda3\current\envs\sd_webui\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "C:\Users\SLAPaper\workspace\stable-diffusion-webui\modules\sd_samplers_kdiffusion.py", line 205, in forward
        uncond = pad_cond(uncond, num_repeats, empty)
      File "C:\Users\SLAPaper\workspace\stable-diffusion-webui\modules\sd_samplers_kdiffusion.py", line 108, in pad_cond
        tensor['crossattn'] = pad_cond(tensor['crossattn'], repeats, empty)
      File "C:\Users\SLAPaper\workspace\stable-diffusion-webui\modules\sd_samplers_kdiffusion.py", line 106, in pad_cond
        return torch.cat([tensor, empty.repeat((tensor.shape[0], repeats, 1))], axis=1)
    RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 1280 but got size 2048 for tensor number 1 in the list.

Update:
It seems that conflicting with optimization padding cond:
image

@SLAPaper SLAPaper changed the title RuntimeError: Sizes of tensors must match except in dimension 1 Conflict with optimization padding cond: "RuntimeError: Sizes of tensors must match except in dimension 1" Aug 6, 2023
@wcde
Copy link
Owner

wcde commented Aug 6, 2023

Padding cond has nothing to do with this, cross attn should always be same size. I could not reproduce this error, something else changes its size. Perhaps this is because of ControlNet?

\extensions\sd-webui-controlnet\scripts\batch_hijack.py", line 42, in processing_process_images_hijack

@SLAPaper
Copy link
Author

SLAPaper commented Aug 6, 2023

Padding cond has nothing to do with this, cross attn should always be same size. I could not reproduce this error, something else changes its size. Perhaps this is because of ControlNet?

\extensions\sd-webui-controlnet\scripts\batch_hijack.py", line 42, in processing_process_images_hijack

but I didn't using ControlNet since there is no XL CN available now
I'll try disable CN plugin for testing

@wcde
Copy link
Owner

wcde commented Aug 6, 2023

It looks like disabled ControlNet is trying to restore original state of model and this breaks everything.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants