"awq/vscode:/vscode.git/clone" did not exist on "0f699cf97e64dc88f4ed476c1388cfead31471c8"
Commit 3571187e authored by thomwolf's avatar thomwolf
Browse files

fix saving models in distributed setting examples

parent d6160224
...@@ -859,6 +859,7 @@ def main(): ...@@ -859,6 +859,7 @@ def main():
optimizer.zero_grad() optimizer.zero_grad()
global_step += 1 global_step += 1
if args.do_train and (args.local_rank == -1 or torch.distributed.get_rank() == 0):
# Save a trained model, configuration and tokenizer # Save a trained model, configuration and tokenizer
model_to_save = model.module if hasattr(model, 'module') else model # Only save the model it-self model_to_save = model.module if hasattr(model, 'module') else model # Only save the model it-self
......
...@@ -1020,7 +1020,7 @@ def main(): ...@@ -1020,7 +1020,7 @@ def main():
optimizer.zero_grad() optimizer.zero_grad()
global_step += 1 global_step += 1
if args.do_train: if args.do_train and (args.local_rank == -1 or torch.distributed.get_rank() == 0):
# Save a trained model, configuration and tokenizer # Save a trained model, configuration and tokenizer
model_to_save = model.module if hasattr(model, 'module') else model # Only save the model it-self model_to_save = model.module if hasattr(model, 'module') else model # Only save the model it-self
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment