I am trying to run the Google Collab notebook https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization.ipynb#scrollTo=IreSlFmlIrIm. Every step is well explained and easy to understand. But I have encountered a problem. while trying to run a specific part of code :
batch_size = 16
model_name = model_checkpoint.split("/")[-1]
args = Seq2SeqTrainingArguments(
output_dir="output_model_T5-small",
evaluation_strategy="epoch",
learning_rate=2e-5,
per_device_train_batch_size=batch_size,
per_device_eval_batch_size=batch_size,
weight_decay=0.01,
save_total_limit=3,
num_train_epochs=1,
predict_with_generate=True,
fp16=True,
push_to_hub=True,
)
I am getting the following error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-36-791f6c1591ac> in <cell line: 10>()
8 model_name = model_checkpoint.split("/")[-1]
9
---> 10 args = Seq2SeqTrainingArguments(
11 output_dir="output_model_T5-small",
12 evaluation_strategy="epoch",
4 frames
/usr/local/lib/python3.10/dist-packages/transformers/training_args.py in _setup_devices(self)
1829 if not is_sagemaker_mp_enabled():
1830 if not is_accelerate_available():
-> 1831 raise ImportError(
1832 f"Using the `Trainer` with `PyTorch` requires `accelerate>={ACCELERATE_MIN_VERSION}`: "
1833 "Please run `pip install transformers[torch]` or `pip install accelerate -U`"
ImportError: Using the `Trainer` with `PyTorch` requires `accelerate>=0.21.0`: Please run `pip install transformers[torch]` or `pip install accelerate -U`
I have tried both the given solutions, "pip install transformers[torch]" and "pip install accelerate -U" but still I got the same error.
Even if I find the version of my accelerate
import accelerate
print(accelerate.__version__)
the output is 0.27.2
I was able to replicate this issue and then solved it by changing the runtime type to T4 GPU. You can do this by going to the settings in the top right corner if you are using colab. See image.