From 5ad237b63051264853efcbd1a4830034ed7e10f9 Mon Sep 17 00:00:00 2001 From: Kaipeng Deng Date: Fri, 28 Jun 2019 20:22:11 +0800 Subject: [PATCH] not enable sync bn in single device (#2607) --- tools/train.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/train.py b/tools/train.py index 242846986..037decdcc 100644 --- a/tools/train.py +++ b/tools/train.py @@ -126,7 +126,8 @@ def main(): build_strategy.memory_optimize = False build_strategy.enable_inplace = True sync_bn = getattr(model.backbone, 'norm_type', None) == 'sync_bn' - build_strategy.sync_batch_norm = sync_bn + # only enable sync_bn in multi-devices + build_strategy.sync_batch_norm = sync_bn and devices_num > 1 train_compile_program = fluid.compiler.CompiledProgram( train_prog).with_data_parallel( loss_name=loss.name, build_strategy=build_strategy) -- GitLab