diff --git a/paddle/fluid/framework/fleet/nccl_wrapper.cc b/paddle/fluid/framework/fleet/nccl_wrapper.cc index 9a39da6dcae1e788d696c92f863e36f41e59ba4b..0df6aca8b12eefb32aec99efc50c1a678e99e656 100644 --- a/paddle/fluid/framework/fleet/nccl_wrapper.cc +++ b/paddle/fluid/framework/fleet/nccl_wrapper.cc @@ -24,9 +24,9 @@ std::shared_ptr NCCLWrapper::s_instance_ = NULL; bool NCCLWrapper::is_initialized_ = false; void NCCLWrapper::InitNCCL() { - platform::dynload::ncclCommInitRank( + PADDLE_ENFORCE(platform::dynload::ncclCommInitRank( &(nccl_info_.comm_), nccl_info_.global_ranks_, nccl_info_.nccl_id_, - nccl_info_.my_global_rank_); + nccl_info_.my_global_rank_)); return; } @@ -55,9 +55,9 @@ void NCCLWrapper::SyncVar(const int root_rank, const Scope& scope, auto var = scope.FindVar(name); LoDTensor* tensor = var->GetMutable(); int32_t total_size = tensor->numel(); - platform::dynload::ncclBcast(reinterpret_cast(tensor->data()), - total_size, ncclFloat, root_rank, - nccl_info_.comm_, nccl_info_.stream_); + PADDLE_ENFORCE(platform::dynload::ncclBcast( + reinterpret_cast(tensor->data()), total_size, ncclFloat, + root_rank, nccl_info_.comm_, nccl_info_.stream_)); cudaStreamSynchronize(nccl_info_.stream_); } } diff --git a/paddle/fluid/framework/fleet/nccl_wrapper.h b/paddle/fluid/framework/fleet/nccl_wrapper.h index 5d73cba892d4f0358141c2b882a461f45d313f2c..eb4e5e19a3a2f7ad79b260261c8c1aa5c5103fa8 100644 --- a/paddle/fluid/framework/fleet/nccl_wrapper.h +++ b/paddle/fluid/framework/fleet/nccl_wrapper.h @@ -24,6 +24,7 @@ limitations under the License. */ #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/framework/variable_helper.h" +#include "paddle/fluid/platform/dynload/nccl.h" #include "paddle/fluid/platform/macros.h" // for DISABLE_COPY_AND_ASSIGN namespace paddle { diff --git a/paddle/fluid/pybind/fleet_wrapper_py.cc b/paddle/fluid/pybind/fleet_wrapper_py.cc index 77f15db8d68da131c892b1a65946c1994b90fd04..2f6a7d2480aedd5bd37d0dbd5ccf64447e4a21ff 100644 --- a/paddle/fluid/pybind/fleet_wrapper_py.cc +++ b/paddle/fluid/pybind/fleet_wrapper_py.cc @@ -36,7 +36,6 @@ limitations under the License. */ #include "paddle/fluid/pybind/fleet_wrapper_py.h" namespace py = pybind11; -namespace pd = paddle::framework; namespace paddle { namespace pybind { diff --git a/paddle/fluid/pybind/nccl_wrapper_py.cc b/paddle/fluid/pybind/nccl_wrapper_py.cc index aec4f4463540df294694aa7a6b1d702867815eac..bbba03f6660fe9ddb14764709ea81a9a82b1b386 100644 --- a/paddle/fluid/pybind/nccl_wrapper_py.cc +++ b/paddle/fluid/pybind/nccl_wrapper_py.cc @@ -29,6 +29,7 @@ limitations under the License. */ #include "paddle/fluid/framework/async_executor.h" #include "paddle/fluid/framework/data_feed.h" #include "paddle/fluid/framework/data_feed.pb.h" +#include "paddle/fluid/framework/fleet/nccl_wrapper.h" #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/inference/io.h" #include "paddle/fluid/platform/place.h"