From d24e046c1eb43c66232436f2ce4d06aea43b7b04 Mon Sep 17 00:00:00 2001 From: chengduoZH Date: Mon, 11 Jun 2018 13:07:42 +0800 Subject: [PATCH] fix allReduce bug --- paddle/fluid/framework/details/all_reduce_op_handle.cc | 2 +- python/paddle/fluid/parallel_executor.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/framework/details/all_reduce_op_handle.cc b/paddle/fluid/framework/details/all_reduce_op_handle.cc index f4c21c795..535bcd46e 100644 --- a/paddle/fluid/framework/details/all_reduce_op_handle.cc +++ b/paddle/fluid/framework/details/all_reduce_op_handle.cc @@ -107,7 +107,7 @@ void AllReduceOpHandle::RunImpl() { auto &trg = *this->local_scopes_[0] ->FindVar(kLocalExecScopeName) ->Get() - ->Var() + ->FindVar(in_var_handles[0]->name_) ->GetMutable(); // Reduce All Tensor to trg in CPU diff --git a/python/paddle/fluid/parallel_executor.py b/python/paddle/fluid/parallel_executor.py index 11e4353d4..50fc085d6 100644 --- a/python/paddle/fluid/parallel_executor.py +++ b/python/paddle/fluid/parallel_executor.py @@ -121,8 +121,9 @@ class ParallelExecutor(object): # performance. Worth tunning for other models in the future. exec_strategy.num_threads = len(self._places) * 4 else: - # Currently num_threads must be 1. - exec_strategy.num_threads = 1 + cpu_num = int( + os.environ.get('CPU_NUM', multiprocessing.cpu_count())) + exec_strategy.num_threads = cpu_num if build_strategy is None: build_strategy = BuildStrategy() -- GitLab