name 'init_empty_weights' is not defined

#11
by estebarb - opened

I'm trying to use this model exactly as the instructions said, but I got the following error:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[5], line 4
      1 from transformers import T5Tokenizer, T5ForConditionalGeneration
      3 tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
----> 4 model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large", device_map="auto")

File ~/src/test/venv/lib/python3.10/site-packages/transformers/modeling_utils.py:2273, in PreTrainedModel.from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
   2271     init_contexts = [deepspeed.zero.Init(config_dict_or_path=deepspeed_config())] + init_contexts
   2272 elif load_in_8bit or low_cpu_mem_usage:
-> 2273     init_contexts.append(init_empty_weights())
   2275 with ContextManagers(init_contexts):
   2276     model = cls(config, *model_args, **model_kwargs)

NameError: name 'init_empty_weights' is not defined

My code is:

from transformers import T5Tokenizer, T5ForConditionalGeneration

tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large", device_map="auto")

Hi @estebarb
Thanks for the issue! Can you double check you are using the latest versions of transformers and accelerate ?
pip install --upgrade transformers accelerate

Sign up or log in to comment