当我尝试在Google Colab中使用transformers库中的Seq 2SeqTrainingArguments类时,遇到了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 )
字符串
环境:
Google Colab 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
型
提前感谢您的帮助!
1条答案
按热度按时间sigwle7e1#
1.卸载
accelerate
和transformers
的现有安装:!pip uninstall accelerate transformers
个1.重新安装所需版本的
accelerate
和transformers
:!pip install accelerate>=0.20.3 transformers
个1.重新启动运行库以应用更改:转到Colab界面顶部的“运行时”菜单,然后选择“重新启动运行时”。
现在,您应该能够使用Seq2SeqTrainingArguments类而不会遇到ImportError。