Skip to content

Move save config before training start log #478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions tools/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ def main(cfg):
start_epoch=start_epoch,
)

# save args used for training
if rank_id in [None, 0]:
with open(os.path.join(cfg.train.ckpt_save_dir, "args.yaml"), "w") as f:
yaml.safe_dump(cfg.to_dict(), stream=f, default_flow_style=False, sort_keys=False)

# log
num_devices = device_num if device_num is not None else 1
global_batch_size = cfg.train.loader.batch_size * num_devices * gradient_accumulation_steps
Expand Down Expand Up @@ -229,12 +234,6 @@ def main(cfg):
f"\nStart training... (The first epoch takes longer, please wait...)\n"
)

# save args used for training
if rank_id in [None, 0]:
with open(os.path.join(cfg.train.ckpt_save_dir, "args.yaml"), "w") as f:
args_text = yaml.safe_dump(cfg.to_dict(), default_flow_style=False, sort_keys=False)
f.write(args_text)

# training
model = ms.Model(train_net)
model.train(
Expand Down