# 'GPT2LMHeadModel' object has no attribute 'push\_to\_hub'

**URL:** <https://discuss.huggingface.co/t/gpt2lmheadmodel-object-has-no-attribute-push-to-hub/11566>\
**Category:** 🤗Transformers\
**Created:** [November 10, 2021, 1:36pm UTC](https://discuss.huggingface.co/t/gpt2lmheadmodel-object-has-no-attribute-push-to-hub/11566 "2021-11-10T13:36:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamiewjm](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/jamiewjm/32/3086_2.png) [@jamiewjm](https://discuss.huggingface.co/u/jamiewjm)\
**Post date:** [November 10, 2021, 1:36pm UTC](https://discuss.huggingface.co/t/gpt2lmheadmodel-object-has-no-attribute-push-to-hub/11566/1 "2021-11-10T13:36:47Z")

</div>

Hello everybody,

I recently fine-tuned a GPT model (GPT2LMHeadModel) and tried to push it to hub. I followed the tutorial but got this strange error: ‘GPT2LMHeadModel’ object has no attribute ‘push\_to\_hub’

 ![Screenshot 2021-11-10 at 21.31.48](https://us1.discourse-cdn.com/hellohellohello/original/2X/2/206724ee1bceca172fd1f044955fba8c9c8f712c.png)

I’ve updated the transformers library to the latest version, as shown in the screenshot. Can anybody help me with that? I’ve been working on this problem for 3 hours but still in vain…

(By the way I was coding on Kaggle)

Any help is appreciated!

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](https://discuss.huggingface.co/u/nielsr)\
**Post date:** [November 10, 2021, 4:45pm UTC](https://discuss.huggingface.co/t/gpt2lmheadmodel-object-has-no-attribute-push-to-hub/11566/2 "2021-11-10T16:45:36Z")

</div>

Hi,

The correct way to push a model to the hub is by typing:

```auto
model.save_pretrained(".", 
        push_to_hub=True, 
        commit_message="First commit",
        repo_path_or_name: Optional[str] = None,
        repo_url: Optional[str] = None,
        use_temp_dir: bool = False,
        commit_message: Optional[str] = None,
        organization: Optional[str] = None,
        private: Optional[bool] = None,
        use_auth_token: Optional[Union[bool, str]] = None,)

```

As can be seen [here](https://github.com/huggingface/transformers/blob/bec02ff209d20d4bca974dab99a8c4e11f5fa737/src/transformers/modeling_utils.py#L980).

---

<div class="post-metadata">

**Author:** ![sgugger](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sgugger/32/2291_2.png) [@sgugger](https://discuss.huggingface.co/u/sgugger)\
**Post date:** [November 10, 2021, 5:18pm UTC](https://discuss.huggingface.co/t/gpt2lmheadmodel-object-has-no-attribute-push-to-hub/11566/3 "2021-11-10T17:18:31Z")

</div>

No that’s incorrect.

Using the `push_to_hub` method is preferred when you just want to push to the Hub, and your model should have that method. Are you absolutely certain the Transformers version is correct inside your notebook? All `PreTrainedModel` have the `push_to_hub` method.

---

<div class="post-metadata">

**Author:** ![jamiewjm](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/jamiewjm/32/3086_2.png) [@jamiewjm](https://discuss.huggingface.co/u/jamiewjm)\
**Post date:** [November 11, 2021, 9:11am UTC](https://discuss.huggingface.co/t/gpt2lmheadmodel-object-has-no-attribute-push-to-hub/11566/4 "2021-11-11T09:11:38Z")

</div>

Hi,

Thanks for the reply!

Yes I used

> pip install transformers==4.12.3

in the notebook to make sure the version is correct. You can see my screenshot that the library version is correct.

Something strange is that I used

> dir(my\_gpt\_model)

to print out all the methods and attributes in the object but there’s no push\_to\_hub method. I even tried to use the save\_pretrained method with the ‘push\_to\_hub’ set to true but it gives me an error saying no such parameter for the method.

It seems that even though pip updated the transformers library, some files in the library remained not updated. I really don’t understand how this happened…

---

<div class="post-metadata">

**Author:** ![jamiewjm](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/jamiewjm/32/3086_2.png) [@jamiewjm](https://discuss.huggingface.co/u/jamiewjm)\
**Post date:** [November 11, 2021, 9:27am UTC](https://discuss.huggingface.co/t/gpt2lmheadmodel-object-has-no-attribute-push-to-hub/11566/5 "2021-11-11T09:27:29Z")

</div>

I just tried again with the same notebook and this time it works!!! I changed nothing actually but just closed it and run it again after 12 hours…

So I guess it’s a bug related to the kaggle notebook. It seems the library files are cached so the newly updated files didn’t take effect somehow.

Thanks anyways!
