ImportError:Using the `Trainer` with `PyTorch` requires `accelerate>=0.20.1`:Please run `pip install transformers[torch]`or`pip install accelerate -U`
Author: smyousaf1
Pull request: no
Labels: name: Good First Issue

### System Info

transformers_version -> (4.35.2)
Environment -> Google Colab

### Who can help?

smyousaf1

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

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

### Reproduction

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-26-cfdcb4612c2d> in <cell line: 1>()
----> 1 training_args = TrainingArguments(
      2     output_dir="my_awesome_food_model",
      3     remove_unused_columns=False,
      4     evaluation_strategy="epoch",
      5     save_strategy="epoch",

4 frames
/usr/local/lib/python3.10/dist-packages/transformers/training_args.py in _setup_devices(self)
   1785         if not is_sagemaker_mp_enabled():
   1786             if not is_accelerate_available(min_version="0.20.1"):
-> 1787                 raise ImportError(
   1788                     "Using the `Trainer` with `PyTorch` requires `accelerate>=0.20.1`: Please run `pip install transformers[torch]` or `pip install accelerate -U`"
   1789                 )

ImportError: Using the `Trainer` with `PyTorch` requires `accelerate>=0.20.1`: Please run `pip install transformers[torch]` or `pip install accelerate -U`


### Expected behavior

I expected it to Train but it produced an error in training segment.

Comments:
Hi @smyousaf1, have you tried upgrading the installed version of accelerate in your environment as indicated by the error message? 

I'm facing the same error on the colab example (with the pytorch implementation): https://huggingface.co/docs/transformers/tasks/sequence_classification . 

The pip command for accelerate is missing, but after including it and installing accelerate, the error keeps showing up, not sure why. Seems like the tutorial could be outdated? I'm my local computer I managed to make it work.

@aghie Are you refreshing the notebook session? If you're updating `accelerate` after already importing it (or it being used by another library) in the same session it will use still use the old version, incompatible version. You should start from a fresh notebook session and install accelerate in one of the first cells. 

Thanks @amyeroberts! I was trying that initially but kept getting the error, but it did work after I made a separate copy of the notebook. 

Do you think it would be possible to update the tutorial? In its current form, it appears odd to run a pip command to install transformers and datasets, only to later find that modifying the notebook to include a second pip command for installing accelerate (and evaluate) is necessary. This only happen in the pytorch version.

Sure! Would you like to open a PR to update to include installing accelerate and evaluate? This way you get the github contribution. 

Hi, I've replicated this issue in both of the notebooks mentioned above and I'd like to take on this issue :)

@MariaHei Great! 

In general, we prioritize based on PRs open, rather than comments on issues. If there's an issue without an open and active PR open, you're free to start work on it :) We find this prevents issues from becoming stale.