3

I am trying to set up hugging face locally and im running into this issue.

NameError: name 'init_empty_weights' is not defined

Here is the code I have tested my installation with

from transformers import pipeline
classifier = pipeline("sentiment-analysis")
text = "I love using Hugging Face Transformers!"
result = classifier(text)
print(result)


transformers: 4.51.0
tokenizers: 0.21.1
accelerate: 1.6.0
sentence-transformers: 4.0.2
huggingface_hub: 0.30.1
I am currently using pytorch-metal mac M3 pro.

What causes this, and how can I fix it?

1
  • 1
    Patch is on its way.
    – cronoik
    Commented Apr 7 at 17:49

2 Answers 2

5

I have the same issue. The issue is related to https://github.com/huggingface/transformers/pull/37337

In my case, installing accelerate fix the issue, as the workaround.

pip install accelerate
1

Try using this version, it should resolve the issue.

transformers==4.50.3

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.