Using run_mlm.py with torch version 1.9.0+cu111
Author: leaBroe
Pull request: no

### System Info

- `transformers` version: 4.40.0.dev0
- Platform: Linux-4.18.0-372.26.1.el8_6.x86_64-x86_64-with-glibc2.28
- Python version: 3.9.19
- Huggingface_hub version: 0.22.2
- Safetensors version: 0.4.2
- Accelerate version: 0.28.0
- Accelerate config: not found
- PyTorch version (GPU?): 2.2.2+cu121 (False)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: yes
- Using distributed or parallel set-up in script?: no

### Who can help?

_No response_

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

I want to run run_mlm.py from https://github.com/huggingface/transformers/blob/main/examples/pytorch/language-modeling/run_mlm.py using GPU support. The pytorch installation compatible with the GPU from the server that I use is: 

```bash
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
```

However, with this version i get the following error:

Attempting uninstall: torch
Found existing installation: torch 2.2.2
Uninstalling torch-2.2.2:
Successfully uninstalled torch-2.2.2
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
accelerate 0.28.0 requires torch>=1.10.0, but you have torch 1.9.0+cu111 which is incompatible.

I tried it with

```bash
pip install -q accelerate==0.5.0
```

nd got the error:

ImportError: Using the `Trainer` with `PyTorch` requires `accelerate>=0.21.0`: Please run `pip install transformers[torch]` or `pip install accelerate -U`

owever if i install version  0.21.0

```bash
pip install -q accelerate==0.21.0
```

I get:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
torchaudio 0.9.0 requires torch==1.9.0, but you have torch 2.2.2 which is incompatible.
torchvision 0.10.0+cu111 requires torch==1.9.0, but you have torch 2.2.2 which is incompatible.

if i then rerun:

```bash
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
```

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
accelerate 0.21.0 requires torch>=1.10.0, but you have torch 1.9.0+cu111 which is incompatible.  

So is there a way to use torch 1.9 and using accelerate for run_mlm.py?  

Steps I did for the installation:  
```bash
conda create --name mlm_transf python=3.9
```

```bash
conda activate mlm_transf
```

```bash
pip install transformers
```

```bash
cd transformers/examples/pytorch/language-modeling/
```

```bash
pip install git+https://github.com/huggingface/transformers
```

```bash
pip install -r requirements.txt
```







### Expected behavior

if i simply install transformers and requirements.txt it works but only on cpu. If i want to use the GPU on the server (NVIDIA A100 80GB PCIe CUDA) i need torch 1.9, which then gives me the errors from above.

Comments:
Hey 🤗  thanks for opening an issue! 

This seems unrelated to transformers, and rather a dependency version issue. 
You should be able to modify the version of the files in the `requirement.txt` of the example folder. 


This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.