Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac M2 error: "RuntimeError: impl: min and input tensors must be of the same shape" #45

Closed
blobbfobb opened this issue Jun 20, 2023 · 1 comment

Comments

@blobbfobb
Copy link

blobbfobb commented Jun 20, 2023

This issue seems to have reappeared.

On my M2 MacBook Air, when I try to generate an image with Dynamic Thresholding enabled, I get the following error:

Error completing request00, ?it/s]
Arguments: ('task(q1b5sqs9msl08ij)', 'female, looking at viewer, frown, blond, updo haircut, huge breasts, curvy, sundress, flower hair ornament, flower field, blue sky, complex background, beautiful lighting, deep shadow, best quality, masterpiece, ultra highres, photorealistic,', 'bad-picture-chill-75v, badhandv4, easynegative, CyberRealistic_Negative-neg, bokeh,', [], 30, 15, False, False, 1, 1, 12, 2906325223.0, -1.0, 0, 0, 0, False, 768, 512, True, 0.4, 1.4, '4x-UltraSharp', 10, 0, 0, 0, '', '', [], 0, False, {'ad_model': 'face_yolov8n.pt', 'ad_prompt': '', 'ad_negative_prompt': '', 'ad_confidence': 0.3, 'ad_mask_min_ratio': 0, 'ad_mask_max_ratio': 1, 'ad_x_offset': 0, 'ad_y_offset': 0, 'ad_dilate_erode': 4, 'ad_mask_merge_invert': 'None', 'ad_mask_blur': 4, 'ad_denoising_strength': 0.4, 'ad_inpaint_only_masked': True, 'ad_inpaint_only_masked_padding': 32, 'ad_use_inpaint_width_height': False, 'ad_inpaint_width': 512, 'ad_inpaint_height': 512, 'ad_use_steps': False, 'ad_steps': 28, 'ad_use_cfg_scale': False, 'ad_cfg_scale': 7, 'ad_restore_face': False, 'ad_controlnet_model': 'None', 'ad_controlnet_weight': 1, 'ad_controlnet_guidance_start': 0, 'ad_controlnet_guidance_end': 1}, {'ad_model': 'None', 'ad_prompt': '', 'ad_negative_prompt': '', 'ad_confidence': 0.3, 'ad_mask_min_ratio': 0, 'ad_mask_max_ratio': 1, 'ad_x_offset': 0, 'ad_y_offset': 0, 'ad_dilate_erode': 4, 'ad_mask_merge_invert': 'None', 'ad_mask_blur': 4, 'ad_denoising_strength': 0.4, 'ad_inpaint_only_masked': True, 'ad_inpaint_only_masked_padding': 32, 'ad_use_inpaint_width_height': False, 'ad_inpaint_width': 512, 'ad_inpaint_height': 512, 'ad_use_steps': False, 'ad_steps': 28, 'ad_use_cfg_scale': False, 'ad_cfg_scale': 7, 'ad_restore_face': False, 'ad_controlnet_model': 'None', 'ad_controlnet_weight': 1, 'ad_controlnet_guidance_start': 0, 'ad_controlnet_guidance_end': 1}, False, 'MultiDiffusion', False, True, 1024, 1024, 96, 96, 48, 4, 'None', 2, False, 10, 1, 1, 64, False, False, False, False, False, 0.4, 0.4, 0.2, 0.2, '', '', 'Background', 0.2, -1.0, False, 0.4, 0.4, 0.2, 0.2, '', '', 'Background', 0.2, -1.0, False, 0.4, 0.4, 0.2, 0.2, '', '', 'Background', 0.2, -1.0, False, 0.4, 0.4, 0.2, 0.2, '', '', 'Background', 0.2, -1.0, False, 0.4, 0.4, 0.2, 0.2, '', '', 'Background', 0.2, -1.0, False, 0.4, 0.4, 0.2, 0.2, '', '', 'Background', 0.2, -1.0, False, 0.4, 0.4, 0.2, 0.2, '', '', 'Background', 0.2, -1.0, False, 0.4, 0.4, 0.2, 0.2, '', '', 'Background', 0.2, -1.0, False, 512, 64, True, True, True, False, True, 8, 100, 'Constant', 0, 'Constant', 0, 4, <scripts.controlnet_ui.controlnet_ui_group.UiControlNetUnit object at 0x28ae9c520>, <scripts.controlnet_ui.controlnet_ui_group.UiControlNetUnit object at 0x28ae9fd30>, <scripts.controlnet_ui.controlnet_ui_group.UiControlNetUnit object at 0x28ae9c640>, False, '1:1,1:2,1:2', '0:0,0:0,0:1', '0.2,0.8,0.8', 20, False, False, 'positive', 'comma', 0, False, False, '', 1, '', [], 0, '', [], 0, '', [], True, False, False, False, 0, None, None, False, None, None, False, None, None, False, 50) {}
Traceback (most recent call last):
  File "/Users/USERNAME/stable-diffusion-webui/modules/call_queue.py", line 57, in f
    res = list(func(*args, **kwargs))
  File "/Users/USERNAME/stable-diffusion-webui/modules/call_queue.py", line 37, in f
    res = func(*args, **kwargs)
  File "/Users/USERNAME/stable-diffusion-webui/modules/txt2img.py", line 57, in txt2img
    processed = processing.process_images(p)
  File "/Users/USERNAME/stable-diffusion-webui/modules/processing.py", line 610, in process_images
    res = process_images_inner(p)
  File "/Users/USERNAME/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 "/Users/USERNAME/stable-diffusion-webui/modules/processing.py", line 728, 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 "/Users/USERNAME/stable-diffusion-webui/modules/processing.py", line 976, in sample
    samples = self.sampler.sample(self, x, conditioning, unconditional_conditioning, image_conditioning=self.txt2img_image_conditioning(x))
  File "/Users/USERNAME/stable-diffusion-webui/modules/sd_samplers_kdiffusion.py", line 383, in sample
    samples = self.launch_sampling(steps, lambda: self.func(self.model_wrap_cfg, x, extra_args={
  File "/Users/USERNAME/stable-diffusion-webui/modules/sd_samplers_kdiffusion.py", line 257, in launch_sampling
    return func()
  File "/Users/USERNAME/stable-diffusion-webui/modules/sd_samplers_kdiffusion.py", line 383, in <lambda>
    samples = self.launch_sampling(steps, lambda: self.func(self.model_wrap_cfg, x, extra_args={
  File "/Users/USERNAME/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/Users/USERNAME/stable-diffusion-webui/repositories/k-diffusion/k_diffusion/sampling.py", line 594, in sample_dpmpp_2m
    denoised = model(x, sigmas[i] * s_in, **extra_args)
  File "/Users/USERNAME/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/Users/USERNAME/stable-diffusion-webui/modules/sd_samplers_kdiffusion.py", line 181, in forward
    denoised = self.combine_denoised(x_out, conds_list, uncond, cond_scale)
  File "/Users/USERNAME/stable-diffusion-webui/extensions/sd-dynamic-thresholding/scripts/dynamic_thresholding.py", line 171, in combine_denoised
    return self.main_class.dynthresh(x_out[:-uncond.shape[0]], denoised_uncond, cond_scale, weights)
  File "/Users/USERNAME/stable-diffusion-webui/extensions/sd-dynamic-thresholding/dynthres_core.py", line 85, in dynthresh
    cfg_clamped = cfg_centered.clamp(-actualMax, actualMax)
RuntimeError: impl: min and input tensors must be of the same shape

The solution offered under the previous bug report does not work for me. My webui-macos-env.sh already calls for a newer version of torch: export TORCH_COMMAND="pip install torch==2.0.1 torchvision==0.15.2".

@mcmonkey4eva
Copy link
Member

The relevant issue #15 (comment) has more comments saying it worked for them.

I notice you haven't mentioned the ./webui.sh --reinstall-torch command in this thread, which that one says is needed

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

No branches or pull requests

2 participants