From 03f79b004475997d94099274da3701ab01c720fd Mon Sep 17 00:00:00 2001 From: Guanghua Yu <742925032@qq.com> Date: Thu, 29 Apr 2021 21:56:22 +0800 Subject: [PATCH] fix sync_bn in cpu (#2825) * 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