Weird evaluation result when using distributed training
## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version: 4.15.0
- Platform: Linux-4.15.0-20-generic-x86_64-with-debian-buster-sid
- Python version: 3.7.11
- PyTorch version (GPU?): 1.10.0+cu113 (True)
- 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?: 
- Using distributed or parallel set-up in script?: 

### Who can help
<!-- Your issue will be replied to more quickly if you can figure out the right person to tag with @
 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.

Models:

- ALBERT, BERT, XLM, DeBERTa, DeBERTa-v2, ELECTRA, MobileBert, SqueezeBert: @LysandreJik
- T5, BART, Marian, Pegasus, EncoderDecoder: @patrickvonplaten
- Blenderbot, MBART: @patil-suraj
- Longformer, Reformer, TransfoXL, XLNet, FNet, BigBird: @patrickvonplaten
- FSMT: @stas00
- Funnel: @sgugger
- GPT-2, GPT: @patrickvonplaten, @LysandreJik
- RAG, DPR: @patrickvonplaten, @lhoestq
- TensorFlow: @Rocketknight1
- JAX/Flax: @patil-suraj
- TAPAS, LayoutLM, LayoutLMv2, LUKE, ViT, BEiT, DEiT, DETR, CANINE: @NielsRogge
- GPT-Neo, GPT-J, CLIP: @patil-suraj
- Wav2Vec2, HuBERT, SpeechEncoderDecoder, UniSpeech, UniSpeechSAT, SEW, SEW-D, Speech2Text: @patrickvonplaten, @anton-l

If the model isn't in the list, ping @LysandreJik who will redirect you to the correct contributor.

Library:

- Benchmarks: @patrickvonplaten
- Deepspeed: @stas00
- Ray/raytune: @richardliaw, @amogkam
- Text generation: @patrickvonplaten @narsil
- Tokenizers: @SaulLu
- Trainer: @sgugger
- Pipelines: @Narsil
- Speech: @patrickvonplaten, @anton-l
- Vision: @NielsRogge, @sgugger

Documentation: @sgugger

Model hub:

- for issues with a model, report at https://discuss.huggingface.co/ and tag the model's creator.

HF projects:

- datasets: [different repo](https://github.com/huggingface/datasets)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj

For research projetcs, please ping the contributor directly. For example, on the following projects:

- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->

@patrickvonplaten, @anton-l

## Information

Model I am using (Bert, XLNet ...):

The problem arises when using:
* [x] the official example scripts: (give details below)
* [ ] my own modified scripts: (give details below)

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [x] my own task or dataset: (give details below)

## To reproduce

Steps to reproduce the behavior:

I use the script [run_speech_recognition_ctc.py](https://github.com/huggingface/transformers/blob/68d925195ede14826dd0e83258b64c2222133988/examples/pytorch/speech-recognition/run_speech_recognition_ctc.py) with my custom dataset but have the same format as the Commonvoice official. In two cases single GPU and multi GPUs, the training loss is fine but the evaluation result is very weird. 

After training the model with multi GPUs, I take the last checkpoint to evaluate. The result WER is totally good. So I thought when combining evaluation results from multi GPUs had something wrong.

1. Trained with multi GPUs.

<img width="1282" alt="Screen Shot 2022-01-11 at 17 21 03" src="https://user-images.githubusercontent.com/8703196/148981486-5306a582-8c40-4d3e-b1c1-aa3e31f52a19.png">

2. Trained with single GPU (in progress)
<img width="1252" alt="Screen Shot 2022-01-11 at 17 32 07" src="https://user-images.githubusercontent.com/8703196/148982838-1b8b1568-d475-43c3-ae65-8a6667dddb58.png">


<!-- If you have code snippets, error messages, stack traces please provide them here as well.
     Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
     Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.-->

## Expected behavior
<!-- A clear and concise description of what you would expect to happen. -->

Hey @nguyenvulebinh,

Could you please share the bash command that you used to start your training? Also how many gpus do you use? 2?<|||||>BTW, we'll announce an event tomorrow where we'll teach you how to train Wav2Vec2 - see: https://github.com/huggingface/transformers/tree/master/examples/research_projects/xls_r. Watch out for the sign-up form if you would like to train wav2vec2 models with us :-)<|||||>Here is the command I used to train the model on 2 GPUs. The arguments of the python script I put into the python file.


```bash
CUDA_VISIBLE_DEVICES=2,4 python -m torch.distributed.launch --nproc_per_node 2 run_speech_recognition_ctc.py
```
```python
# "--dataset_name", "common_voice",
# "--dataset_config_name", "vi",
"--data_processing_cache_folder", "./data-bin/processed/cache",
"--preprocessing_num_workers", "30",
"--model_name_or_path", "./model-bin/wav2vec_pretrained/large/",
"--output_dir", "./wav2vec2-large-vlsp2020",
"--logging_dir", "./wav2vec2-large-vlsp2020/log",
"--logging_steps", "100",
"--overwrite_output_dir",
"--num_train_epochs", "50",
"--per_device_train_batch_size", "48",
"--gradient_accumulation_steps", "1",
"--learning_rate", "1e-4",
"--warmup_ratio", "{}".format(1/20),
"--evaluation_strategy", "steps",
"--text_column_name", "sentence",
"--save_steps", "5000",
"--eval_steps", "2500",
"--warmup_steps", "5000",
"--layerdrop", "0.1",
"--hidden_dropout", "0.3",
"--save_total_limit", "3",
"--freeze_feature_encoder",
"--delay_epoch_finetune_wav2vec", "1",
"--gradient_checkpointing",
"--fp16",
#"--preprocessing_only",
"--metric_for_best_model", "wer",
"--greater_is_better", "False",
"--group_by_length",
"--length_column_name", "input_length",
"--dataloader_num_workers", "10",
"--do_train",
"--do_eval",
"--ignore_data_skip"
```<|||||>I've never seen `delay_epoch_finetune_wav2vec` before - are you using a custom loop?<|||||>Yes, it is a little custom for freezing the wav2vec layer for one epoch before fine-tuning all layers. I do that thing by using a Callback. I don't think it is the problem.<|||||>Hmm, this makes it very difficult to guess possible errors here though if it's a costum loop. Could you maybe try to ask help on the forum: https://discuss.huggingface.co/ instead?<|||||>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/master/CONTRIBUTING.md) are likely to be ignored.