huggingface / transformers

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
https://huggingface.co/transformers
Apache License 2.0
132.7k stars 26.44k forks source link

`pip install accelerate` (and similar) error messages should specify min version #31583

Closed mikelmcdaniel closed 1 month ago

mikelmcdaniel commented 3 months ago

System Info

Who can help?

@muellerzr

Information

Tasks

Reproduction

  1. Have accelerate installed at a low version (e.g. 0.10.0)
  2. Run the following code:
    
    import torch
    from transformers import pipeline

pipe = pipeline("text-generation", model="TinyLlama/TinyLlama-1.1B-Chat-v1.0", torch_dtype=torch.bfloat16, device_map="auto")


3. Error message "ImportError: Using `low_cpu_mem_usage=True` or a `device_map` requires Accelerate: `pip install accelerate`" pops up

Ideally, the error message would be "ImportError: Using `low_cpu_mem_usage=True` or a `device_map` requires Accelerate: `pip install 'accelerate>=0.21.0'`"

---

### Expected behavior

Error message would specify the `utils.import_utils.ACCELERATE_MIN_VERSION`:

"ImportError: Using `low_cpu_mem_usage=True` or a `device_map` requires Accelerate: `pip install 'accelerate>=0.21.0'`"
mikelmcdaniel commented 3 months ago

Potential fix (that I didn't test): https://github.com/mikelmcdaniel/transformers/commit/157e20f9a57b097b4c756558d12834696527ebb3

LysandreJik commented 2 months ago

cc @muellerzr @SunMarc this seems like valuable feedback

muellerzr commented 2 months ago

Yes agreed, I'm reworking the imports today so I'll make sure to run through any accelerated-related errs like this to specify min versions :)