# Can't load weights for gpt2 error

**URL:** <https://discuss.huggingface.co/t/cant-load-weights-for-gpt2-error/255>\
**Category:** Beginners\
**Created:** [July 13, 2020, 4:57pm UTC](https://discuss.huggingface.co/t/cant-load-weights-for-gpt2-error/255 "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](https://discuss.huggingface.co/u/aclifton314)\
**Post date:** [July 13, 2020, 4:57pm UTC](https://discuss.huggingface.co/t/cant-load-weights-for-gpt2-error/255/1 "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!
