Fix push_to_hub for TPUs (#12895)

This commit is contained in:
Sylvain Gugger 2021-07-26 17:10:34 -04:00 committed by GitHub
parent b3f95dceca
commit ba15fe7995
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2515,10 +2515,11 @@ class Trainer:
Returns:
The url of the commit of your model in the given repository.
"""
if not self.args.should_save:
return
self.create_model_card(model_name=self.args.push_to_hub_model_id, **kwargs)
if self.args.should_save:
self.create_model_card(model_name=self.args.push_to_hub_model_id, **kwargs)
# Needs to be executed on all processes for TPU training, but will only save on the processed determined by
# self.args.should_save.
self.save_model()
# Only push from one node.