Commit 8353ad23 authored by Fei Sun's avatar Fei Sun Committed by Facebook GitHub Bot
Browse files

Set gradient as bucket view

Summary:
Pull Request resolved: https://github.com/facebookresearch/d2go/pull/526

Add a config variable: DDP_GRADIENT_AS_BUCKET_VIEW. Pass it to DDP. This variable reduces the memory consumption of the model.

Reviewed By: tglik

Differential Revision: D44273339

fbshipit-source-id: 272e2ffbea89532a55df0ebdb3bd49f0df7d78a5
parent 04a2956d
...@@ -72,6 +72,8 @@ def _add_detectron2go_runner_default_cfg(_C: CN) -> None: ...@@ -72,6 +72,8 @@ def _add_detectron2go_runner_default_cfg(_C: CN) -> None:
_C.MODEL.DDP_FIND_UNUSED_PARAMETERS = False _C.MODEL.DDP_FIND_UNUSED_PARAMETERS = False
# Set FP16 gradient compression for DistributedDataParallel. # Set FP16 gradient compression for DistributedDataParallel.
_C.MODEL.DDP_FP16_GRAD_COMPRESS = False _C.MODEL.DDP_FP16_GRAD_COMPRESS = False
# Specify the gradients as views
_C.MODEL.DDP_GRADIENT_AS_BUCKET_VIEW = False
# Set default optimizer # Set default optimizer
_C.SOLVER.OPTIMIZER = "sgd" _C.SOLVER.OPTIMIZER = "sgd"
......
...@@ -93,6 +93,7 @@ def main( ...@@ -93,6 +93,7 @@ def main(
else [comm.get_local_rank()], else [comm.get_local_rank()],
broadcast_buffers=False, broadcast_buffers=False,
find_unused_parameters=cfg.MODEL.DDP_FIND_UNUSED_PARAMETERS, find_unused_parameters=cfg.MODEL.DDP_FIND_UNUSED_PARAMETERS,
gradient_as_bucket_view=cfg.MODEL.DDP_GRADIENT_AS_BUCKET_VIEW,
) )
logger.info("Starting train..") logger.info("Starting train..")
......
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