Skip to content

Can't load weights for GPT2 error #5787

Description

@aclifton314

System Info

Pop!_OS 20.04
Pytorch: 1.5.1
Transformers: 2.11.0
Python: 3.7.6

Details

I am working behind a proxy. If I run the following:

from transformers import GPT2Tokenizer
proxies = {'http':'http://my.proxy.com:port', 'https':'https://my.proxy.com:port'}
tokenizer = GPT2Tokenizer.from_pretrained("gpt2", proxies=proxies)

The tokenizer gets downloaded. However, if I run:

from transformers import GPT2LMHeadModel
proxies = {'http':'http://my.proxy.com:port', 'https':'https://my.proxy.com:port'}
model = GPT2LMHeadModel.from_pretrained("gpt2", proxies=proxies)

I get the following error:

Traceback (most recent call last):
  File "/path/to/anaconda3/lib/python3.7/site-packages/transformers/modeling_utils.py", line 638, in from_pretrained
    raise EnvironmentError
OSError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/path/to/text_gen_w_transformers/finetune_test.py", line 28, in <module>
    model = GPT2LMHeadModel.from_pretrained("gpt2", proxies=proxies)
  File "/path/to/anaconda3/lib/python3.7/site-packages/transformers/modeling_utils.py", line 645, in from_pretrained
    raise EnvironmentError(msg)
OSError: Can't load weights for 'gpt2'. Make sure that:

- 'gpt2' is a correct model identifier listed on 'https://huggingface.co/models'

- or 'gpt2' is the correct path to a directory containing a file named one of pytorch_model.bin, tf_model.h5, model.ckpt.

Any thoughts about what might be the issue? Thanks in advance for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions