InvokeAI icon indicating copy to clipboard operation
InvokeAI copied to clipboard

[bug]: 2.3.0 / MacOs: k_dpm_2 and k_dmp_2_a samplers fails using diffuser model

Open i3oc9i opened this issue 2 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

OS

macOS

GPU

mps

VRAM

128G

What happened?

When I select the k_dpm_2 and the k_dmp_2_a samplers the generation fails with reason:

Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't support float64. Please use float32 instead.

Tested diffuser models: SD15, SD21-768, and Dreamlike.

NOTE: those samplers work as expected when .ckpt/.safetensor are used.

Screenshots

>> Image Generation Parameters:

{'prompt': 'frontal symmetrical portrait of a woman, perfect textured skin, clean hair, dry skin, clear skin, airbrushed, bright eye makeup, warrior body, photo by mario testino, 8k octane render, cinematic, hyper detailed, micro details, insanely detailed, trending on artstation, concept art, 'iterations': 1, 'steps': 20, 'cfg_scale': 7.5, 'threshold': 0, 'perlin': 0, 'height': 512, 'width': 512, 'sampler_name': 'k_dpm_2', 'seed': 99590666, 'progress_images': False, 'progress_latents': True, 'save_intermediates': 5, 'generation_mode': 'txt2img', 'init_mask': '...', 'seamless': False, 'hires_fix': False, 'variation_amount': 0}

>> ESRGAN Parameters: False
>> Facetool Parameters: False
>> Setting Sampler to k_dpm_2 (KDPM2DiscreteScheduler)
Generating:   0%|                                                                                                                                                                                                                                                                                                                          | 0/1 [00:00<?, ?it/s]/Users/ivano/invokeai/.venv/lib/python3.10/site-packages/diffusers/schedulers/scheduling_k_dpm_2_discrete.py:142: UserWarning: The operator 'aten::roll' is not currently supported on the MPS backend and will fall back to run on the CPU. This may have performance implications. (Triggered internally at /Users/runner/work/pytorch/pytorch/pytorch/aten/src/ATen/mps/MPSFallback.mm:11.)
  sigmas_interpol = sigmas.log().lerp(sigmas.roll(1).log(), 0.5).exp()
Generating:   0%|                                                                                                                                                                                                                                                                                                                          | 0/1 [00:00<?, ?it/s]
Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't support float64. Please use float32 instead.


Traceback (most recent call last):
  File "/Users/ivano/invokeai/.venv/lib/python3.10/site-packages/invokeai/backend/invoke_ai_web_server.py", line 1204, in generate_images
    self.generate.prompt2image(
  File "/Users/ivano/invokeai/.venv/lib/python3.10/site-packages/ldm/generate.py", line 516, in prompt2image
    results = generator.generate(
  File "/Users/ivano/invokeai/.venv/lib/python3.10/site-packages/ldm/invoke/generator/base.py", line 112, in generate
    image = make_image(x_T)
  File "/Users/ivano/invokeai/.venv/lib/python3.10/site-packages/ldm/invoke/generator/txt2img.py", line 40, in make_image
    pipeline_output = pipeline.image_from_embeddings(
  File "/Users/ivano/invokeai/.venv/lib/python3.10/site-packages/ldm/invoke/generator/diffusers_pipeline.py", line 340, in image_from_embeddings
    result_latents, result_attention_map_saver = self.latents_from_embeddings(
  File "/Users/ivano/invokeai/.venv/lib/python3.10/site-packages/ldm/invoke/generator/diffusers_pipeline.py", line 363, in latents_from_embeddings
    self.scheduler.set_timesteps(num_inference_steps, device=self.unet.device)
  File "/Users/ivano/invokeai/.venv/lib/python3.10/site-packages/diffusers/schedulers/scheduling_k_dpm_2_discrete.py", line 152, in set_timesteps
    timesteps = torch.from_numpy(timesteps).to(device)
TypeError: Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't support float64. Please use float32 instead.

Additional context

No response

Contact Details

No response

i3oc9i avatar Feb 09 '23 14:02 i3oc9i

Confirmed, I get this error using these two samplers as well. M2 Max MacBook Pro 64GB, MacOS 13.2.

Adreitz avatar Feb 11 '23 18:02 Adreitz

According to my test this issue is solved with v2.3.1-RC4, but I will close it when the official 2.3.1 version will be released. @Adreitz can you confirm my founding ?

i3oc9i avatar Feb 24 '23 11:02 i3oc9i

This is expected to be resolved as the fix was in diffusers v13.

psychedelicious avatar Feb 24 '23 23:02 psychedelicious

yes its is

i3oc9i avatar Feb 25 '23 08:02 i3oc9i