未验证 提交 b986a451 编写于 作者: K Kaipeng Deng 提交者: GitHub

not use syncbn in single device (#2442)

上级 9f27a5ca
...@@ -95,8 +95,12 @@ def train(): ...@@ -95,8 +95,12 @@ def train():
fluid.io.load_vars(exe, cfg.pretrain, predicate=if_exist) fluid.io.load_vars(exe, cfg.pretrain, predicate=if_exist)
build_strategy = fluid.BuildStrategy() build_strategy = fluid.BuildStrategy()
build_strategy.memory_optimize = False #gc and memory optimize may conflict build_strategy.memory_optimize = False #gc and memory optimize may conflict
build_strategy.sync_batch_norm = cfg.syncbn syncbn = cfg.syncbn
if syncbn and devices_num <= 1:
print("Disable syncbn in single device")
syncbn = False
build_strategy.sync_batch_norm = syncbn
compile_program = fluid.compiler.CompiledProgram(fluid.default_main_program( compile_program = fluid.compiler.CompiledProgram(fluid.default_main_program(
)).with_data_parallel( )).with_data_parallel(
loss_name=loss.name, build_strategy=build_strategy) loss_name=loss.name, build_strategy=build_strategy)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册