Skip to content

NameError: name 'AcceleratorState' is not defined #23898

@ezyang

Description

@ezyang

System Info

This script fails on 68d53bc but passes on de9255d

Hopefully the problem is pretty clear from the message.

(/home/ezyang/local/debug/pytorch-env) [[email protected] ~/local/debug]$ pp python transformers/examples/pytorch/speech-recognition/run_speech_recognition_ctc.py     --dataset_name="common_voice"     --model_name_or_path="facebook/wav2vec2-large-xlsr-53"     --dataset_config_name="tr"     --output_dir="./wav2vec2-common_voice-tr-demo-dist"     --preprocessing_num_workers="16"     --overwrite_output_dir     --num_train_epochs="15"     --per_device_train_batch_size="4"     --gradient_accumulation_steps="1"     --learning_rate="3e-4"     --warmup_steps="500"     --evaluation_strategy="steps"     --text_column_name="sentence"     --save_steps="400"     --eval_steps="100"     --logging_steps="1"     --layerdrop="0.0"     --save_total_limit="3"     --freeze_feature_encoder     --gradient_checkpointing     --chars_to_ignore , ? . ! - \; \: \" “ % ‘ ” �     --fp16     --group_by_length     --do_train --do_eval     --torch_compile True
Traceback (most recent call last):
  File "/data/users/ezyang/debug/transformers/examples/pytorch/speech-recognition/run_speech_recognition_ctc.py", line 775, in <module>
    main()
  File "/data/users/ezyang/debug/transformers/examples/pytorch/speech-recognition/run_speech_recognition_ctc.py", line 380, in main
    model_args, data_args, training_args = parser.parse_args_into_dataclasses()
  File "/home/ezyang/local/debug/pytorch-env/lib/python3.10/site-packages/transformers/hf_argparser.py", line 346, in parse_args_into_dataclasses
    obj = dtype(**inputs)
  File "<string>", line 111, in __init__
  File "/home/ezyang/local/debug/pytorch-env/lib/python3.10/site-packages/transformers/training_args.py", line 1340, in __post_init__
    and (self.device.type != "cuda")
  File "/home/ezyang/local/debug/pytorch-env/lib/python3.10/site-packages/transformers/training_args.py", line 1764, in device
    return self._setup_devices
  File "/home/ezyang/local/debug/pytorch-env/lib/python3.10/site-packages/transformers/utils/generic.py", line 54, in __get__
    cached = self.fget(obj)
  File "/home/ezyang/local/debug/pytorch-env/lib/python3.10/site-packages/transformers/training_args.py", line 1670, in _setup_devices
    AcceleratorState._reset_state()
NameError: name 'AcceleratorState' is not defined

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

python transformers/examples/pytorch/speech-recognition/run_speech_recognition_ctc.py --dataset_name="common_voice" --model_name_or_path="facebook/wav2vec2-large-xlsr-53" --dataset_config_name="tr" --output_dir="./wav2vec2-common_voice-tr-demo-dist" --preprocessing_num_workers="16" --overwrite_output_dir --num_train_epochs="15" --per_device_train_batch_size="4" --gradient_accumulation_steps="1" --learning_rate="3e-4" --warmup_steps="500" --evaluation_strategy="steps" --text_column_name="sentence" --save_steps="400" --eval_steps="100" --logging_steps="1" --layerdrop="0.0" --save_total_limit="3" --freeze_feature_encoder --gradient_checkpointing --chars_to_ignore , ? . ! - \; \: \" “ % ‘ ” � --fp16 --group_by_length --do_train --do_eval --torch_compile True

Expected behavior

doesn't error this way

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions