Skip to content

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

Closed

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

Activity

  1. added
    bug
    on Oct 15, 2022
  2. vvsotnikov commented on Oct 15, 2022

    @vvsotnikov
    Contributor

    I have the same issue with diffusers 0.5.1 and pytorch 1.14.0.dev20221014.

  3. klyuhang9 commented on Oct 15, 2022

    @klyuhang9

    I meet the same issue with diffusers 0.5.1 ,pytorch 1.11.0

  4. dkackman commented on Oct 16, 2022

    @dkackman

    Don't think it's specific to MPS. Getting the same on a Ryzan/NVIDIA combo

  5. patrickvonplaten commented on Oct 16, 2022

    @patrickvonplaten
    Contributor

    Hey @FahimF,

    Thanks a lot for the issue! Could you try updating your transformers version here?
    Also see: #859

    I'll now also open a PR to prevent this for lower transformers versions

  6. FahimF commented on Oct 17, 2022

    @FahimF
    Author

    @patrickvonplaten Upgrading to the the latest transformers did the trick. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions