Skip to content

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

Description

@engrussman

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

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
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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions