Skip to content

Commit

Permalink
API: Change --batch-size argument to be across all nodes, not one
Browse files Browse the repository at this point in the history
Changed the behaviour of main_lincls.py to be consistent with the
behaviour of main_moco.py.
https://github.com/facebookresearch/moco-v3/blob/878544a/main_moco.py#L206
  • Loading branch information
scottclowe committed Nov 25, 2021
1 parent 7074f47 commit a29021a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main_lincls.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
parser.add_argument('-b', '--batch-size', default=1024, type=int,
metavar='N',
help='mini-batch size (default: 1024), this is the total '
'batch size of all GPUs on the current node when '
'batch size of all GPUs on all nodes when '
'using Data Parallel or Distributed Data Parallel')
parser.add_argument('--lr', '--learning-rate', default=0.1, type=float,
metavar='LR', help='initial (base) learning rate', dest='lr')
Expand Down Expand Up @@ -207,7 +207,7 @@ def print_pass(*args):
# When using a single GPU per process and per
# DistributedDataParallel, we need to divide the batch size
# ourselves based on the total number of GPUs we have
args.batch_size = int(args.batch_size / ngpus_per_node)
args.batch_size = int(args.batch_size / args.world_size)
args.workers = int((args.workers + ngpus_per_node - 1) / ngpus_per_node)
model = torch.nn.parallel.DistributedDataParallel(model, device_ids=[args.gpu])
else:
Expand Down

0 comments on commit a29021a

Please sign in to comment.