'GPT2LMHeadModel' object has no attribute 'push_to_hub'
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.481182×727 218 KBI’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!
2021-11-10T16:45:36Z
Hi,The correct way to push a model to the hub is by typing: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 seenhere.
2021-11-10T17:18:31Z
No that’s incorrect.Using thepush_to_hubmethod 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? AllPreTrainedModelhave thepush_to_hubmethod.
2021-11-11T09:11:38Z
Hi,Thanks for the reply!Yes I usedpip install transformers==4.12.3in 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 useddir(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…
2021-11-11T09:27:29Z
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!