Search code examples
huggingface-transformershuggingface

Error ("bus error") running the simplest example on Hugging Face Transformers Pipeline (Macos M1)


I'm trying to follow the quick tour example here: https://huggingface.co/docs/transformers/quicktour

and i'm getting a "bus error".

My env is:

  • MacOS Sonoma 14.7, Apple M1 Max chip
  • Python 3.11.5
  • pip install transformers datasets evaluate accelerate
  • pip install tf-keras

Running this code:

from transformers import pipeline

classifier = pipeline("sentiment-analysis")
result = classifier("We are very happy to show you the 🤗 Transformers library.")
print(result)

And getting this result:

No model was supplied, defaulted to distilbert/distilbert-base-uncased-finetuned-sst-2-english and revision 714eb0f (https://huggingface.co/distilbert/distilbert-base-uncased-finetuned-sst-2-english).

Using a pipeline without specifying a model name and revision in production is not recommended. [1]

92883 bus error python main.py

Any ideas?

Thanks for your help.


Solution

  • using device=0 (the first GPU) solved this:

    classifier = pipeline("sentiment-analysis", device=0)