NVIDIA / NVIDIA/apex

When to validate and save model while using apex's DDP

Open
#118 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
9k
Forks
1.5k
Avg merge
2d 4h
Merged PRs (30d)
3

Description

When I use SyncBN and apex.parallel.DistributedDataParallel together, I found that all print() functions, both in train and validate part, print twice. The problem is, I save best model by validating periodly, and I found that there are two best models saved by two GPUs. I don't know what to do.

Then, I checked this file, and found this line
if batch_idx % args.log_interval == 0 and args.local_rank == 0:
and this
if args.local_rank == 0:.

So you only print training loss and do validation when args.local_rank == 0, which I think equals to gpu=0 in my case. Does this means gpu 0 is the master and gpu 1 is slave, only gpu 0 would compute the total loss, just like what torch.nn.DataParallel do?

And If I want to do validation and save best model, do I only need to validate on gpu 0 and only save the model on gpu0? Then if I want to use saved model, just like dealing with the model saved when using torch.nn.DataParallel?

Sorry for a rookie's question.Thanks

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with examples/distributed/main.py and the uses of args.local_rank shown in the issue. Clarify the expected validation, logging, and checkpoint-saving behavior when using SyncBN with apex.parallel.DistributedDataParallel, including how a saved model should be reused.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
distributed-systems, machine-learning
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.