Can't use Trainer( ) in Colab

trainer = Trainer()

ImportError Traceback (most recent call last)
in <cell line: 1>()

5 frames
/usr/local/lib/python3.10/dist-packages/transformers/training_args.py in _setup_devices(self)
1714 if not is_sagemaker_mp_enabled():
1715 if not is_accelerate_available(min_version=“0.20.1”):
→ 1716 raise ImportError(
1717 “Using the Trainer with PyTorch requires accelerate>=0.20.1: Please run pip install transformers[torch] or pip install accelerate -U
1718 )

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.

1 Like

Hi! As per the error message, you need to update the accelerate package with !pip install accelerate -U and then restart the runtime by clicking RuntimeRestart runtime for the update to take effect.

1 Like