Skip to content

Commit

Permalink
update reduce config (#18335)
Browse files Browse the repository at this point in the history
test=release/1.5
  • Loading branch information
chengduo committed Jun 26, 2019
1 parent e0cb671 commit 401c03f
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions paddle/fluid/framework/parallel_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -314,25 +314,23 @@ ParallelExecutor::ParallelExecutor(const std::vector<platform::Place> &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 "
"the Program will be copied %lu copies",
(member_->use_cuda_ ? "CUDAPlace" : "CPUPlace"), places.size(),
places.size());

// Step 1. Bcast the bcast_vars to devs.
// Create local scopes
if (local_scopes.empty()) {
Expand Down

0 comments on commit 401c03f

Please sign in to comment.