diffusers 0.5.1 crashs on MPS with unexpected keyword argument 'device_map' error
See original GitHub issueDescribe 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
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
TypeError: __init__() got an unexpected keyword ... - GitHub
from torch import autocast from diffusers import ... Full error message: ... __init__() got an unexpected keyword argument 'device_map'.
Read more >patrickvonplaten - PullAnswer
have a small problem after upgrade diffusers and others ... diffusers 0.5.1 crashs on MPS with unexpected keyword argument 'device_map' error.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@patrickvonplaten Upgrading to the the latest transformers did the trick. Thanks!
Hey @FahimF,
Thanks a lot for the issue! Could you try updating your
transformers
version here? Also see: https://github.com/huggingface/diffusers/issues/859I’ll now also open a PR to prevent this for lower transformers versions