notebooks icon indicating copy to clipboard operation
notebooks copied to clipboard

Fixing Error in TrainingArguments (Sec.2 / Ch.3) [Colab]

Open 0ssamaak0 opened this issue 1 year ago • 4 comments
trafficstars

running this cell in colab

from transformers import TrainingArguments

training_args = TrainingArguments("test-trainer")

results in the error

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
[<ipython-input-2-11170ce17e38>](https://localhost:8080/#) in <cell line: 3>()
      1 from transformers import TrainingArguments
      2 
----> 3 training_args = TrainingArguments("test-trainer")

4 frames
[/usr/local/lib/python3.10/dist-packages/transformers/training_args.py](https://localhost:8080/#) in _setup_devices(self)
   1785         if not is_sagemaker_mp_enabled():
   1786             if not is_accelerate_available(min_version="0.20.1"):
-> 1787                 raise ImportError(
   1788                     "Using the `Trainer` with `PyTorch` requires `accelerate>=0.20.1`: Please run `pip install transformers[torch]` or `pip install accelerate -U`"
   1789                 )

ImportError: Using the `Trainer` with `PyTorch` requires `accelerate>=0.20.1`: Please run `pip install transformers[torch]` or `pip install accelerate -U`

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

the fix is to add accelerate in this pip install cell (first cell)

!pip install datasets evaluate transformers[sentencepiece] accelerate -U

@sgugger

0ssamaak0 avatar Jan 05 '24 12:01 0ssamaak0

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@scndel thanks 😁

0ssamaak0 avatar Feb 06 '24 13:02 0ssamaak0

@scndel can you merge it?

0ssamaak0 avatar Mar 17 '24 04:03 0ssamaak0

note: if editing the first cell manually after running into the problem, you need to restart it after updating (e.g. os.kill(os.getpid(),9)) as https://github.com/huggingface/notebooks/pull/442 did

unhammer avatar May 16 '24 10:05 unhammer