Ch. 4, ImportError: Using the `Trainer` with `PyTorch` requires `accelerate>=0.19.0`: Please run `pip install transformers[torch]` or `pip install accelerate -U`
Closed this issue · 1 comments
andysingal commented
Hi,
I was running the code:
#@title Step 12: Initializing the Trainer
from transformers import Trainer, TrainingArguments
training_args = TrainingArguments(
output_dir="./KantaiBERT",
overwrite_output_dir=True,
num_train_epochs=1,
per_device_train_batch_size=64,
save_steps=10_000,
save_total_limit=2,
)
trainer = Trainer(
model=model,
args=training_args,
data_collator=data_collator,
train_dataset=dataset,
)
and got error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
[<ipython-input-63-8c3183b44e84>](https://localhost:8080/#) in <cell line: 4>()
2 from transformers import Trainer, TrainingArguments
3
----> 4 training_args = TrainingArguments(
5 output_dir="./KantaiBERT",
6 overwrite_output_dir=True,
4 frames
[/usr/local/lib/python3.10/dist-packages/transformers/training_args.py](https://localhost:8080/#) in _setup_devices(self)
1670 if not is_sagemaker_mp_enabled():
1671 if not is_accelerate_available(check_partial_state=True):
-> 1672 raise ImportError(
1673 "Using the `Trainer` with `PyTorch` requires `accelerate>=0.19.0`: Please run `pip install transformers[torch]` or `pip install accelerate -U`"
1674 )
ImportError: Using the `Trainer` with `PyTorch` requires `accelerate>=0.19.0`: 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.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
i tried to install :
!pip install torch
!pip install git+https://github.com/huggingface/accelerate
but was not helpful.
Checking to see if there is anything else i can do to address the issue.
Thanks,
Ankush Singal
andysingal commented
I was able to find the answer from: https://discuss.huggingface.co/t/importerror-using-the-trainer-with-pytorch-seq2seqtrainingarguments/40599