{"id":1035,"hash":"9442ea07daf86c8100e13f9dc857939b2c3db325c00b765f8439182b399cf5c7","pattern":"NameError: name &#39;PartialState&#39; is not defined error while training hugging face wave2vec model","full_message":"Here is the code block which caused the error\n\ntraining_args = TrainingArguments(\n    output_dir=\"my_awesome_mind_model\",\n    evaluation_strategy=\"epoch\",\n    save_strategy=\"epoch\",\n    learning_rate=3e-5,\n    per_device_train_batch_size=32,\n    gradient_accumulation_steps=4,\n    per_device_eval_batch_size=32,\n    num_train_epochs=10,\n    warmup_ratio=0.1,\n    logging_steps=10,\n    load_best_model_at_end=True,\n    metric_for_best_model=\"accuracy\",\n    push_to_hub=True,\n)\n\ntrainer = Trainer(\n    model=model,\n    args=training_args,\n    train_dataset=dataset[\"train\"],\n    # eval_dataset=encoded_minds[\"test\"],\n    tokenizer=feature_extractor,\n    compute_metrics=compute_metrics,\n)\n\ntrainer.train()\n\ngetting the following error\n\nNameError                                 Traceback (most recent call last)\n in <cell line: 1>()\n1 training_args = TrainingArguments(\n2     output_dir=\"my_awesome_mind_model\",\n3     evaluation_strategy=\"epoch\",\n4     save_strategy=\"epoch\",\n5     learning_rate=3e-5,\n\n4 frames\n/usr/local/lib/python3.10/dist-packages/transformers/training_args.py in _setup_devices(self)\n1629             self._n_gpu = 1\n1630         else:\n1631             self.distributed_state = PartialState(backend=self.ddp_backend)\n1632             self._n_gpu = 1\n1633         if not is_sagemaker_mp_enabled():\n\nNameError: name 'PartialState' is not defined\n\nI 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.","ecosystem":"pypi","package_name":"huggingface-transformers","package_version":null,"solution":"As of 2023-05-11:\n\nThe error seems to be caused by an issue in the huggingface/accelerate library.\n\nYou can try following solutions:\n\nReinstall transformers & accelerate\npip uninstall -y transformers accelerate\npip install transformers accelerate\n\nIf you are using colab/Jupyter, make sure to restart the notebook's Runtime.\n\nInstall dev version of accelerate\npip install git+https://github.com/huggingface/accelerate\n\nReverse to previous version of transformers (4.28.0)\n# You might also need to uninstall transformers first: pip uninstall -y transformers\npip install transformers==4.28.0","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/76225595/nameerror-name-partialstate-is-not-defined-error-while-training-hugging-face","votes":11,"created_at":"2026-04-19T04:52:12.296533+00:00","updated_at":"2026-04-19T04:52:12.296533+00:00"}