NameError: name ‘PartialState’ is defined error while training hugging face wave2vec model.

huangapple go评论67阅读模式
英文:

NameError: name 'PartialState' is not defined error while training hugging face wave2vec model

问题

以下是导致错误的代码块:

training_args = TrainingArguments(
    output_dir="my_awesome_mind_model",
    evaluation_strategy="epoch",
    save_strategy="epoch",
    learning_rate=3e-5,
    per_device_train_batch_size=32,
    gradient_accumulation_steps=4,
    per_device_eval_batch_size=32,
    num_train_epochs=10,
    warmup_ratio=0.1,
    logging_steps=10,
    load_best_model_at_end=True,
    metric_for_best_model="accuracy",
    push_to_hub=True,
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=dataset["train"],
    # eval_dataset=encoded_minds["test"],
    tokenizer=feature_extractor,
    compute_metrics=compute_metrics,
)

trainer.train()

遇到以下错误:

NameError: name 'PartialState' is not defined

英文:

Here is the code block which caused the error

training_args = TrainingArguments(
    output_dir="my_awesome_mind_model",
    evaluation_strategy="epoch",
    save_strategy="epoch",
    learning_rate=3e-5,
    per_device_train_batch_size=32,
    gradient_accumulation_steps=4,
    per_device_eval_batch_size=32,
    num_train_epochs=10,
    warmup_ratio=0.1,
    logging_steps=10,
    load_best_model_at_end=True,
    metric_for_best_model="accuracy",
    push_to_hub=True,
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=dataset["train"],
    # eval_dataset=encoded_minds["test"],
    tokenizer=feature_extractor,
    compute_metrics=compute_metrics,
)

trainer.train()

getting the following error

> NameError Traceback (most recent call last)
> <ipython-input-72-9be933d63072> in <cell line: 1>()
> 1 training_args = TrainingArguments(
> 2 output_dir="my_awesome_mind_model",
> 3 evaluation_strategy="epoch",
> 4 save_strategy="epoch",
> 5 learning_rate=3e-5,
>
> 4 frames
> /usr/local/lib/python3.10/dist-packages/transformers/training_args.py in _setup_devices(self)
> 1629 self._n_gpu = 1
> 1630 else:
> 1631 self.distributed_state = PartialState(backend=self.ddp_backend)
> 1632 self._n_gpu = 1
> 1633 if not is_sagemaker_mp_enabled():
>
> NameError: name 'PartialState' is not defined

I am trying to follow the audio classification guide of hugging face(link on another dataset but upon running the training args code i am getting name "PartialState" not defined error.

答案1

得分: 19

截至2023年5月11日:

这个错误似乎是由huggingface/accelerate库中的一个问题引起的。

你可以尝试以下解决方案:

重新安装transformers & accelerate

pip uninstall -y transformers accelerate
pip install transformers accelerate

如果你正在使用colab/Jupyter,请确保重新启动笔记本的运行时。

安装accelerate的开发版本

pip install git+https://github.com/huggingface/accelerate

回退到transformers的先前版本(4.28.0)

# 你可能需要先卸载transformers:pip uninstall -y transformers
pip install transformers==4.28.0
英文:

As of 2023-05-11:

The error seems to be caused by an issue in the huggingface/accelerate library.

You can try following solutions:

Reinstall transformers & accelerate

pip uninstall -y transformers accelerate
pip install transformers accelerate

If you are using colab/Jupyter, make sure to restart the notebook's Runtime.

Install dev version of accelerate

pip install git+https://github.com/huggingface/accelerate

Reverse to previous version of transformers (4.28.0)

# You might also need to uninstall transformers first: pip uninstall -y transformers
pip install transformers==4.28.0

答案2

得分: 1

安装并升级加速库,然后重新启动你的笔记本的运行时。

英文:

pip install --upgrade accelerate and restart your notebook's runtime.

huangapple
  • 本文由 发表于 2023年5月11日 16:28:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76225595.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定