Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: name 'AcceleratorState' is not defined #23898

Closed
2 of 4 tasks
ezyang opened this issue May 31, 2023 · 3 comments · Fixed by #23906
Closed
2 of 4 tasks

NameError: name 'AcceleratorState' is not defined #23898

ezyang opened this issue May 31, 2023 · 3 comments · Fixed by #23906
Assignees

Comments

@ezyang
Copy link
Contributor

ezyang commented May 31, 2023

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) [ezyang@devgpu019.ftw1 ~/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

@sgugger
Copy link
Collaborator

sgugger commented May 31, 2023

I think you don't have accelerate installed, which is now a required dependency for the Trainer: pip install accelerate.

@ezyang
Copy link
Contributor Author

ezyang commented May 31, 2023

Ah ok, in that case, probably a requirements.txt just needs to get updated somewhere. (Also, naively, I would have expected an ImportError if I had a missing dependency, not a NameError)

@muellerzr
Copy link
Contributor

Thanks @ezyang, with #23906 we'll raise an ImportError properly :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants