Skip to content

TypeError: __init__() got an unexpected keyword argument 'device_map' #859

Closed

Description

@klyuhang9

Describe the bug

Hi, friends, I meet a problem I hope to get your help.

When I run the code as follow:

`from diffusers import StableDiffusionPipeline
import torch

pipe = StableDiffusionPipeline.from_pretrained("PATH_OF_MODEL/stable-diffusion",device_map="auto",torch_type=torch.float16, revision="fp16")
`

I save the model in the path "PATH_OF_MODEL/stable-diffusion" from the https://huggingface.co/CompVis/stable-diffusion-v1-4/tree/main
Then, I get the error as follow:

Traceback (most recent call last):
File "", line 1, in
File "/home/klyuhang9/miniconda3/envs/ldm/lib/python3.8/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 "/home/klyuhang9/miniconda3/envs/ldm/lib/python3.8/site-packages/transformers/modeling_utils.py", line 2024, in from_pretrained
model = cls(config, *model_args, **model_kwargs)
TypeError: init() got an unexpected keyword argument 'device_map'

My environment: python=3.8.5, diffusers=0.5.1 torch=1.11.0, transformers = 4.19.2, ftfy=6.1.1,accelerate=0.13.1 which run on ubuntu=22.04.

I don't know why, I sincerely to get your team help.Thanks,bro!

Reproduction

`from diffusers import StableDiffusionPipeline
import torch

pipe = StableDiffusionPipeline.from_pretrained("PATH_OF_MODEL/stable-diffusion",device_map="auto",torch_type=torch.float16, revision="fp16")
`

Logs

'Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/klyuhang9/miniconda3/envs/ldm/lib/python3.8/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 "/home/klyuhang9/miniconda3/envs/ldm/lib/python3.8/site-packages/transformers/modeling_utils.py", line 2024, in from_pretrained
    model = cls(config, *model_args, **model_kwargs)
TypeError: __init__() got an unexpected keyword argument 'device_map''

System Info

My environment: python=3.8.5, diffusers=0.5.1 torch=1.11.0, transformers = 4.19.2, ftfy=6.1.1,accelerate=0.13.1 which run on ubuntu=22.04.

Package Version


accelerate 0.13.1
brotlipy 0.7.0
certifi 2022.9.24
cffi 1.15.1
charset-normalizer 2.0.4
cryptography 37.0.1
diffusers 0.5.1
filelock 3.8.0
ftfy 6.1.1
huggingface-hub 0.10.1
idna 3.3
importlib-metadata 5.0.0
mkl-fft 1.3.1
mkl-random 1.2.2
mkl-service 2.4.0
numpy 1.19.2
opencv-python 4.6.0.66
packaging 21.3
Pillow 9.2.0
pip 20.3.3
psutil 5.9.2
pycparser 2.21
pyOpenSSL 22.0.0
pyparsing 3.0.9
PySocks 1.7.1
PyYAML 6.0
regex 2022.9.13
requests 2.28.1
setuptools 63.4.1
six 1.16.0
tokenizers 0.12.1
torch 1.11.0
torchvision 0.12.0
tqdm 4.64.1
transformers 4.19.2
typing-extensions 4.3.0
urllib3 1.26.11
wcwidth 0.2.5
wheel 0.37.1
zipp 3.9.0

Activity

  1. added
    bug
    on Oct 16, 2022
  2. dkackman commented on Oct 16, 2022

    @dkackman

    started happening spontaneously for me this morning. (diffusers 0.5.1)

  3. anfeirr commented on Oct 16, 2022

    @anfeirr

    yes, I've got the same bug

  4. patrickvonplaten commented on Oct 16, 2022

    @patrickvonplaten
    Contributor

    Hey,

    Could you try updating your transformers version to at least 4.20 ?
    Big model inference was introduced in version 4.20.0 in Transformers see here: https://github.com/huggingface/transformers/releases/tag/v4.20.0

    If you run:

    pip install --upgrade transformers

    I think it should work

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