Facing AttributeError: 'DataParallel' object has no attribute 'resize_token_embeddings'
## 🐛 AttributeError: 'DataParallel' object has no attribute 'resize_token_embeddings'

<!-- Important information -->

I'm facing AttributeError: 'DataParallel' object has no attribute 'resize_token_embeddings' while performing fine-tuning by using run_lm_finetuning.py. 

Following are the arguments:

 python run_lm_finetuning.py --train_data_file=sample_text.txt --model_type=gpt2 --model_name_or_path=gpt2 --output_dir=op --mlm --do_train --overwrite_output_dir --do_lower_case --save_steps=50

I tried to change the model but faced same error :

## Detailed error message 

Traceback (most recent call last):
  File "run_lm_finetuning.py", line 556, in <module>
    main()
  File "run_lm_finetuning.py", line 508, in main
    global_step, tr_loss = train(args, train_dataset, model, tokenizer)
  File "run_lm_finetuning.py", line 218, in train
    model.resize_token_embeddings(len(tokenizer))
  File "/nipa/anaconda3/envs/nlp/lib/python3.7/site-packages/torch/nn/modules/module.py", line 585, in __getattr__
    type(self).__name__, name))
AttributeError: 'DataParallel' object has no attribute 'resize_token_embeddings'

I've two GPUs install but I've not passed any argument to utilize both GPUs


+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.87.01    Driver Version: 418.87.01    CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla V100-PCIE...  On   | 00000000:00:05.0 Off |                  Off |
| N/A   39C    P0    43W / 250W |   4976MiB / 32480MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
|   1  Tesla V100-PCIE...  On   | 00000000:00:06.0 Off |                  Off |
| N/A   35C    P0    26W / 250W |     11MiB / 32480MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0     26820      C   python                                      1653MiB |
|    0     69641      C   python                                      1657MiB |
|    0    114902      C   python                                      1655MiB |
+-----------------------------------------------------------------------------+
<|||||>I ran into the same issue. It is not fixed in the newest released version, 2.2.1.<|||||>Same issue when using multi-gpu. Single gpu case works.

e.g. running the command as `CUDA_VISIBLE_DEVICES=1 python run_lm_finetuning.py ...`<|||||>As mentioned by @kalpitdixit using Single GPU works fine but on multiple GPUs, problem persists. <|||||>Ok should be fixed on master, thanks!