From 135a59ed453b38bcb0200dd9e170365150095da4 Mon Sep 17 00:00:00 2001 From: chengduo Date: Wed, 26 Jun 2019 12:57:52 +0800 Subject: [PATCH] update reduce config (#18334) test=develop --- paddle/fluid/framework/parallel_executor.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/paddle/fluid/framework/parallel_executor.cc b/paddle/fluid/framework/parallel_executor.cc index 035a62688e6..4b3eb56abf8 100644 --- a/paddle/fluid/framework/parallel_executor.cc +++ b/paddle/fluid/framework/parallel_executor.cc @@ -314,18 +314,18 @@ ParallelExecutor::ParallelExecutor(const std::vector &places, member_->use_all_reduce_ = build_strategy.reduce_ == BuildStrategy::ReduceStrategy::kAllReduce; member_->nranks_ = build_strategy.num_trainers_ * places.size(); + if (!member_->use_all_reduce_ && member_->nranks_ == 1) { + LOG(INFO) << "If you set build_strategy.reduce with 'Reduce'," + "the number of places should be greater than 1."; + member_->build_strategy_.reduce_ = + BuildStrategy::ReduceStrategy::kAllReduce; + member_->use_all_reduce_ = true; + } #if defined(PADDLE_WITH_CUDA) && defined(_WIN32) if (member_->use_cuda_) { PADDLE_ENFORCE(places.size() == 1, "Windows can support Single GPU only."); } #endif - if (!member_->use_all_reduce_) { - if (places.size() == 1) { - LOG(INFO) << "If you set build_strategy.reduce with 'Reduce'," - "the number of places should be greater than 1."; - member_->use_all_reduce_ = true; - } - } LOG(INFO) << string::Sprintf( "The number of %s, which is used in ParallelExecutor, is %lu. And " -- GitLab