From 82e7a90bfeaffd85a641941ada8587f8951e0c60 Mon Sep 17 00:00:00 2001 From: littletomatodonkey <2120160898@bit.edu.cn> Date: Wed, 4 Nov 2020 11:06:23 +0800 Subject: [PATCH] fix dist eval (#364) --- tools/eval.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/eval.py b/tools/eval.py index f95dcafc..65a3de39 100644 --- a/tools/eval.py +++ b/tools/eval.py @@ -59,9 +59,14 @@ def main(args, return_dict={}): paddle.disable_static(place) - strategy = paddle.distributed.init_parallel_env() + use_data_parallel = int(os.getenv("PADDLE_TRAINERS_NUM", 1)) != 1 + config["use_data_parallel"] = use_data_parallel + net = program.create_model(config.ARCHITECTURE, config.classes_num) - net = paddle.DataParallel(net, strategy) + if config["use_data_parallel"]: + strategy = paddle.distributed.init_parallel_env() + net = paddle.DataParallel(net, strategy) + init_model(config, net, optimizer=None) valid_dataloader = Reader(config, 'valid', places=place)() net.eval() -- GitLab