在 Google Colab 中尝试使用 Transformers 库中的 Seq2SeqTrainingArguments 类进行加速时,我遇到了 ImportError。这是错误消息:
ImportError Traceback (most recent call last)
<ipython-input-18-90ef02e6f0d8> in <cell line: 3>()
1 from transformers import Seq2SeqTrainer, Seq2SeqTrainingArguments
2
----> 3 training_args = Seq2SeqTrainingArguments(
4 output_dir="whisper", # change to a repo name of your choice
5 per_device_train_batch_size=16,
4 frames
/usr/local/lib/python3.10/dist-packages/transformers/training_args.py in _setup_devices(self)
1729 if not is_sagemaker_mp_enabled():
1730 if not is_accelerate_available(min_version="0.20.1"):
-> 1731 raise ImportError(
1732 "Using the `Trainer` with `PyTorch` requires `accelerate>=0.20.1`: Please run `pip install transformers[torch]` or `pip install accelerate -U`"
1733 )
环境:
谷歌合作实验室 Python 3.10 CUDA 版本 11.8
我尝试执行以下操作,但仍然遇到相同的错误:
!pip install accelerate>=0.20.1
!pip install torch torchvision torchaudio -f https://download.pytorch.org/whl/cu111/torch_stable.html
!pip install transformers
提前感谢您的帮助!
accelerate
和 transformers
:!pip uninstall accelerate transformers
accelerate
和 transformers
:!pip install accelerate>=0.20.3 transformers
现在,您应该能够使用 Seq2SeqTrainingArguments 类而不会遇到 ImportError。
仅从运行时菜单重新启动会话在我的情况下有效。