# Can't load weights for gpt2 error

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-load-weights-for-gpt2-error%2F255%3E%5C
**Category:** Beginners\
**Created:** [July 13, 2020, 4:57pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-load-weights-for-gpt2-error%2F255 "2020-07-13T16:57:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aclifton314](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/aclifton314/32/55465_2.png) [@aclifton314](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Faclifton314)%5C
**Post date:** [July 13, 2020, 4:57pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-load-weights-for-gpt2-error%2F255%2F1 "2020-07-13T16:57:28Z")

</div>

**SYSTEM**  
OS: Pop!\_os 19.10  
Transformers: 3.0.2

I have the following code:

```python
from transformers import GPT2LMHeadModel
model = GPT2LMHeadModel.from_pretrained('gpt2')

```

After running it, I get this error:

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

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/path/to/project/text_gen_w_transformers/finetune_gpt2.py", line 8, in <module>
    model = GPT2LMHeadModel.from_pretrained('gpt2')
  File "/path/to/anaconda3/lib/python3.7/site-packages/transformers/modeling_utils.py", line 665, 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.

```

I checked the website and, indeed, `gpt2` is one of the models listed. Any thoughts? Thanks in advance!
