TrainingArgument does not work on colab
I was following chapter 3 of the NLP course on Fine-tuning a model with the Trainer API and when executing the command in colabtraining_args = TrainingArguments(“test-trainer”)I get:ImportError                               Traceback (most recent call last)in <cell line: 1>()----> 1 training_args = TrainingArguments(output_dir=“test-trainer”)4 frames/usr/local/lib/python3.10/dist-packages/transformers/training_args.py in _setup_devices(self)1670         if not is_sagemaker_mp_enabled():1671             if not is_accelerate_available(min_version=“0.20.1”):→ 1672                 raise ImportError(1673                     “Using theTrainerwithPyTorchrequiresaccelerate>=0.20.1: Please runpip install transformers[torch]orpip install accelerate -U”1674                 )ImportError: Using theTrainerwithPyTorchrequiresaccelerate>=0.20.1: Please runpip install transformers[torch]orpip install accelerate -UNOTE: If your import is failing due to a missing package, you canmanually install dependencies using either !pip or !apt.To view examples of installing some common dependencies, click the“Open Examples” button below.I try to pip install the recommended ones but never work for me.Help!
2023-06-16T16:31:44Z
I experienced the same import error when running the following script from the hugging face transformer quick tour. Installing the 2 mentioned libraries did not resolve.from transformers import TrainingArgumentstraining_args = TrainingArguments(output_dir=“./pt_training”,learning_rate=2e-5,per_device_train_batch_size=8,per_device_eval_batch_size=8,num_train_epochs=2,)
2023-06-18T09:17:42Z
I encountered the same problem when I run the code below.from transformers import TrainingArgumentstraining_args = TrainingArguments(“test-trainer”)ERROR：Using theTrainerwithPyTorchrequiresaccelerate>=0.20.1: Please runpip install  transformers[torch]orpip install accelerate -UBut installing the 2 mentioned libraries did not resolve.I don’t know what to do now. Help!
2023-06-18T11:20:16Z
For me help reset environment and install older transformers!pip install transformers==4.17
2023-06-19T13:15:54Z
!pip install transformers==4.17 did not resolve the import error. I forgot to mention I am running the code in Google Colab.
2023-06-19T23:26:59Z
I’m getting the same error in the colab notebook for theNLP Course: Lesson 3 - Fine-tuning  model with the Trainer API. In order to get around it you can:Runpip install accelerate -Uin a cellIn the top menu clickRuntime→Restart RuntimeDo not rerun any cells with!pip installin themRerun all the other code cells and you should be good to go!On a side note, be sure to turn on a GPU for this notebook by clickingEdit→Notebook Settings→GPU type- from the top menu. This was the next thing that got me : )
2023-06-26T03:50:00Z
Has this concern been resolved?
2023-07-06T04:42:52Z
Thanks for this, it worked for me.
2023-08-28T13:13:15Z
Yess worked for me too! Thanks,
2023-09-22T07:04:48Z
MatthewVedder:pip install accelerate -UThanks it worked but can you please explain this issue.
2023-10-03T07:45:56Z
Thank you. Because of the above workaround I fixed the error
2023-11-11T10:08:21Z
Also works for me! Thank you!
2024-01-04T16:01:58Z
This works in colab. Thanks a lot and greatly appreciate you!
2024-01-19T04:08:57Z
This resolved the issue. Thanks!
2024-02-20T21:45:57Z
Worked for me, thank you!
2024-05-04T09:20:08Z
Thank U for sharing
2024-06-05T16:04:32Z
Thank you so much, it worked like a charm
2024-06-11T07:40:56Z
is very nice idea