# Problem with push\_to\_hub

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fproblem-with-push-to-hub%2F8273%3E%5C
**Category:** 🤗Transformers\
**Created:** [July 12, 2021, 2:44pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fproblem-with-push-to-hub%2F8273 "2021-07-12T14:44:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![YusufSahin99](https://avatars.discourse-cdn.com/v4/letter/y/50afbb/32.png) [@YusufSahin99](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FYusufSahin99)%5C
**Post date:** [July 12, 2021, 2:44pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fproblem-with-push-to-hub%2F8273%2F1 "2021-07-12T14:44:21Z")

</div>

Hello everyone. I’m trying to upload my fine-tuned GPT-2 Model to Model Hub.  
When I try to use the uploading function push\_to\_hub I get the following error:  
`AttributeError: 'GPT2Model' object has no attribute 'push_to_hub'`  
In the documentation it says that I can push the model with this function.  
Can anybody help please?

---

<div class="post-metadata">

**Author:** ![sgugger](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sgugger/32/2291_2.png) [@sgugger](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsgugger)%5C
**Post date:** [July 12, 2021, 3:24pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fproblem-with-push-to-hub%2F8273%2F2 "2021-07-12T15:24:30Z")

</div>

You need to update your Transformers library to the latest version.

---

<div class="post-metadata">

**Author:** ![YusufSahin99](https://avatars.discourse-cdn.com/v4/letter/y/50afbb/32.png) [@YusufSahin99](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FYusufSahin99)%5C
**Post date:** [July 12, 2021, 6:29pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fproblem-with-push-to-hub%2F8273%2F4 "2021-07-12T18:29:23Z")

</div>

Thank you so much. I have another question. Is there a way to push a model to the model hub after training without saving the new model to the disk with trainer.save\_model() ? Would Trainer.push\_to\_hub do that or is it for pushing just the trainer instance? If yes how can I give my authentication token as a parameter to trainer.push\_to\_hub method?

---

<div class="post-metadata">

**Author:** ![sgugger](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sgugger/32/2291_2.png) [@sgugger](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsgugger)%5C
**Post date:** [July 12, 2021, 6:43pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fproblem-with-push-to-hub%2F8273%2F5 "2021-07-12T18:43:45Z")

</div>

You can set your token in the training arguments inside `push_to_hub_token`.  
The `Trainer` will save the model on disk with `save_model`, as you need to save it to the repo of the model you will be using before it can git push it to the model hub.

---

<div class="post-metadata">

**Author:** ![YusufSahin99](https://avatars.discourse-cdn.com/v4/letter/y/50afbb/32.png) [@YusufSahin99](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FYusufSahin99)%5C
**Post date:** [July 13, 2021, 9:07am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fproblem-with-push-to-hub%2F8273%2F6 "2021-07-13T09:07:46Z")

</div>

So you mean I should set push\_to\_hub\_token in Training arguments. Then train the model and save it using trainer.save\_model() function. Then I should just recreate it from the saved file using

```auto
fine_tuned_model = AutoModel.from_pretrained("./file_path")

```

And then finally push it to hub using

```auto
fine_tuned_model.push_to_hub("Name of model")

```

---

<div class="post-metadata">

**Author:** ![sgugger](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sgugger/32/2291_2.png) [@sgugger](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsgugger)%5C
**Post date:** [July 13, 2021, 11:44am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fproblem-with-push-to-hub%2F8273%2F7 "2021-07-13T11:44:35Z")

</div>

No, you should just do `trainer.push_to_hub()` once you’re done with training. Look at any of the [notebooks examples](https://huggingface.co/transformers/master/notebooks.html#examples) for more context, or the [push to hub video](https://youtu.be/A5IWIxsHLUw).

---

<div class="post-metadata">

**Author:** ![YusufSahin99](https://avatars.discourse-cdn.com/v4/letter/y/50afbb/32.png) [@YusufSahin99](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FYusufSahin99)%5C
**Post date:** [July 14, 2021, 2:20pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fproblem-with-push-to-hub%2F8273%2F8 "2021-07-14T14:20:04Z")

</div>

Thank you very much. I was able to solve my problem after I saw the training argument “push\_to\_hub\_model\_id” and transformers-cli from your example notebook “Train a language model”.

---

<div class="post-metadata">

**Author:** ![SRDdev](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/srddev/32/22612_2.png) [@SRDdev](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FSRDdev)%5C
**Post date:** [January 28, 2023, 6:56am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fproblem-with-push-to-hub%2F8273%2F9 "2023-01-28T06:56:59Z")

</div>

‘Functional’ object has no attribute ‘push\_to\_hub’

 ![screenshot-colab.research.google.com-2023.01.28-12_24_29](https://us1.discourse-cdn.com/hellohellohello/original/2X/c/c43f450851679c9822f4ebb68d2f0e0981e9307e.png)

I am facing this issue regarding push\_to\_hub API which does not support Functional models from TensorFlow. My model is an NMT that has custom objects.  
It is a custom model which I have built from scratch and does not use any methods like from\_pretrained.  
I want to push it to huggingface as well as create a pipeline

Please help
