From 6af489978e1d26f845a65cb6ee14b534cabb07d5 Mon Sep 17 00:00:00 2001 From: Guanghua Yu <742925032@qq.com> Date: Thu, 29 Apr 2021 21:40:26 +0800 Subject: [PATCH] [cherry-pick] fix sync bn in cpu (#2826) * fix sync_bn in cpu * fix sync_bn in cpu --- tools/eval.py | 3 +++ tools/infer.py | 3 +++ tools/train.py | 3 +++ 3 files changed, 9 insertions(+) diff --git a/tools/eval.py b/tools/eval.py index 65080e90e..5df7a0774 100755 --- a/tools/eval.py +++ b/tools/eval.py @@ -117,6 +117,9 @@ def main(): place = paddle.set_device('gpu' if cfg.use_gpu else 'cpu') + if 'norm_type' in cfg and cfg['norm_type'] == 'sync_bn' and not cfg.use_gpu: + cfg['norm_type'] = 'bn' + if FLAGS.slim_config: cfg = build_slim_model(cfg, FLAGS.slim_config, mode='eval') diff --git a/tools/infer.py b/tools/infer.py index d4f213ead..7ea0d2353 100755 --- a/tools/infer.py +++ b/tools/infer.py @@ -141,6 +141,9 @@ def main(): place = paddle.set_device('gpu' if cfg.use_gpu else 'cpu') + if 'norm_type' in cfg and cfg['norm_type'] == 'sync_bn' and not cfg.use_gpu: + cfg['norm_type'] = 'bn' + if FLAGS.slim_config: cfg = build_slim_model(cfg, FLAGS.slim_config, mode='test') diff --git a/tools/train.py b/tools/train.py index b0c49966e..d9ef6d6f2 100755 --- a/tools/train.py +++ b/tools/train.py @@ -123,6 +123,9 @@ def main(): place = paddle.set_device('gpu' if cfg.use_gpu else 'cpu') + if 'norm_type' in cfg and cfg['norm_type'] == 'sync_bn' and not cfg.use_gpu: + cfg['norm_type'] = 'bn' + if FLAGS.slim_config: cfg = build_slim_model(cfg, FLAGS.slim_config) -- GitLab