python-3.x ImportError与Transformers和Accelerate在Google Colab:未找到Seq2SeqTrainingArguments

nafvub8i  于 2023-08-08  发布在  Python
关注(0)|答案(1)|浏览(228)

当我尝试在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


提前感谢您的帮助!

sigwle7e

sigwle7e1#

1.卸载acceleratetransformers的现有安装:
!pip uninstall accelerate transformers
1.重新安装所需版本的acceleratetransformers
!pip install accelerate>=0.20.3 transformers
1.重新启动运行库以应用更改:转到Colab界面顶部的“运行时”菜单,然后选择“重新启动运行时”。
现在,您应该能够使用Seq2SeqTrainingArguments类而不会遇到ImportError。

相关问题