Skip to content

diffusers 0.5.1 crashs on MPS with unexpected keyword argument 'device_map' error #852

@FahimF

Description

@FahimF

Describe the bug

Trying to run Stable Diffusion code with the default scheduler and it simply crashes out every single time with the following error:

Traceback (most recent call last):
  File "/Users/fahim/Code/Python/sd-gui/test.py", line 6, in <module>
    pipe = StableDiffusionPipeline.from_pretrained("stable-diffusion-v1-4").to(device)
  File "/Users/fahim/miniconda3/envs/ml/lib/python3.9/site-packages/diffusers/pipeline_utils.py", line 517, in from_pretrained
    loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwargs)
  File "/Users/fahim/miniconda3/envs/ml/lib/python3.9/site-packages/transformers/modeling_utils.py", line 1843, in from_pretrained
    model = cls(config, *model_args, **model_kwargs)
TypeError: __init__() got an unexpected keyword argument 'device_map'

Reproduction

Just run the following code:

import torch
from diffusers import StableDiffusionPipeline

device = torch.device("cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu")
pipe = StableDiffusionPipeline.from_pretrained("stable-diffusion-v1-4").to(device)
prompt = "an elf sitting on a toadstool"
result = pipe(prompt)
image = result["sample"][0]

Logs

No response

System Info

macOS Monterey 12.6
Apple M1 Max 32GB
diffusers 0.5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions