From 5e1640f7e403c7fd2641d685479ab2375601d89e Mon Sep 17 00:00:00 2001 From: Jacek Czaja Date: Mon, 12 Feb 2018 05:36:24 -0800 Subject: [PATCH 1/5] - Fix MKLDNN build type to match Paddle build type --- cmake/external/mkldnn.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/external/mkldnn.cmake b/cmake/external/mkldnn.cmake index 89fc34796a..3b8314a06b 100644 --- a/cmake/external/mkldnn.cmake +++ b/cmake/external/mkldnn.cmake @@ -56,6 +56,7 @@ ExternalProject_Add( PREFIX ${MKLDNN_SOURCES_DIR} UPDATE_COMMAND "" CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${MKLDNN_INSTALL_DIR} + CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} CMAKE_ARGS -DMKLROOT=${MKLML_ROOT} CMAKE_ARGS -DCMAKE_C_FLAGS=${MKLDNN_CFLAG} CMAKE_ARGS -DCMAKE_CXX_FLAGS=${MKLDNN_CXXFLAG} From ed5dc3d4ae705c879369774e1491aee6967426a2 Mon Sep 17 00:00:00 2001 From: fengjiayi Date: Tue, 13 Feb 2018 10:49:45 +0800 Subject: [PATCH 2/5] remove 'friend lod_tensor in tensor' --- paddle/fluid/framework/tensor.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/paddle/fluid/framework/tensor.h b/paddle/fluid/framework/tensor.h index f95af384eb..6f878541e6 100644 --- a/paddle/fluid/framework/tensor.h +++ b/paddle/fluid/framework/tensor.h @@ -130,8 +130,6 @@ class Tensor { inline void set_layout(const DataLayout layout) { layout_ = layout; } private: - friend class LoDTensor; - /** * @note Placeholder hides type T, so it doesn't appear as a template * parameter of Variable. From 8b01546fe44c5c42bc4a72958ed06d04178854f5 Mon Sep 17 00:00:00 2001 From: QI JUN Date: Tue, 13 Feb 2018 11:48:20 +0800 Subject: [PATCH 3/5] fix compile warning (#8430) --- paddle/fluid/operators/detection_map_op.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/paddle/fluid/operators/detection_map_op.h b/paddle/fluid/operators/detection_map_op.h index 39d17a7cb3..92e0510839 100644 --- a/paddle/fluid/operators/detection_map_op.h +++ b/paddle/fluid/operators/detection_map_op.h @@ -151,7 +151,7 @@ class DetectionMAPOpKernel : public framework::OpKernel { for (int n = 0; n < batch_size; ++n) { std::map> boxes; - for (int i = label_index[n]; i < label_index[n + 1]; ++i) { + for (size_t i = label_index[n]; i < label_index[n + 1]; ++i) { Box box(labels(i, 2), labels(i, 3), labels(i, 4), labels(i, 5)); int label = labels(i, 0); auto is_difficult = labels(i, 1); @@ -167,7 +167,7 @@ class DetectionMAPOpKernel : public framework::OpKernel { auto detect_index = detect_lod[0]; for (int n = 0; n < batch_size; ++n) { std::map>> boxes; - for (int i = detect_index[n]; i < detect_index[n + 1]; ++i) { + for (size_t i = detect_index[n]; i < detect_index[n + 1]; ++i) { Box box(detect(i, 2), detect(i, 3), detect(i, 4), detect(i, 5)); int label = detect(i, 0); auto score = detect(i, 1); @@ -269,8 +269,8 @@ class DetectionMAPOpKernel : public framework::OpKernel { std::map>>& pos) { const T* pos_data = pos_tensor.data(); auto pos_data_lod = pos_tensor.lod(); - for (int i = 0; i < pos_data_lod.size(); ++i) { - for (int j = pos_data_lod[0][i]; j < pos_data_lod[0][i + 1]; ++j) { + for (size_t i = 0; i < pos_data_lod.size(); ++i) { + for (size_t j = pos_data_lod[0][i]; j < pos_data_lod[0][i + 1]; ++j) { T score = pos_data[j * 2]; int flag = 1; if (pos_data[j * 2 + 1] < kEPS) flag = 0; From dafc7e3643798a13e32f20ee6c6014cfa40bbe0c Mon Sep 17 00:00:00 2001 From: emailweixu Date: Tue, 13 Feb 2018 09:52:18 -0800 Subject: [PATCH 4/5] Check data format consistency in data_feeder (#8417) --- python/paddle/v2/fluid/data_feeder.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/paddle/v2/fluid/data_feeder.py b/python/paddle/v2/fluid/data_feeder.py index f9e2f3e6a2..070bcadd71 100644 --- a/python/paddle/v2/fluid/data_feeder.py +++ b/python/paddle/v2/fluid/data_feeder.py @@ -107,6 +107,9 @@ class DataFeeder(object): dtype=dtype)) for each_sample in iterable: + assert len(each_sample) == len(converter), ( + "The number of fields in data (%s) does not match " + + "len(feed_list) (%s)") % (len(each_sample), len(converter)) for each_converter, each_slot in six.zip(converter, each_sample): each_converter.feed(each_slot) ret_dict = {} From 87f4311a88694284d95e81460a5adeda47e4367d Mon Sep 17 00:00:00 2001 From: "Yang Yang(Tony)" Date: Tue, 13 Feb 2018 14:05:33 -0800 Subject: [PATCH 5/5] compile with nccl2 (#8411) * compile with nccl2 * add ncclGroup; it is necessary in nccl2 * add back libnccl-dev --- CMakeLists.txt | 1 - paddle/fluid/platform/CMakeLists.txt | 2 +- paddle/fluid/platform/dynload/CMakeLists.txt | 2 +- paddle/fluid/platform/nccl_test.cu | 2 ++ paddle/scripts/docker/build.sh | 5 ++++- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb91e3b369..5db5c228be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,7 +142,6 @@ include(external/boost) # download boost include(external/any) # download libn::any include(external/eigen) # download eigen3 include(external/pybind11) # download pybind11 -include(external/nccl) include(external/cares) include(external/grpc) diff --git a/paddle/fluid/platform/CMakeLists.txt b/paddle/fluid/platform/CMakeLists.txt index 32e768fdf4..0d0cee21d1 100644 --- a/paddle/fluid/platform/CMakeLists.txt +++ b/paddle/fluid/platform/CMakeLists.txt @@ -1,5 +1,5 @@ if(WITH_GPU) - cc_library(enforce SRCS enforce.cc DEPS nccl) + cc_library(enforce SRCS enforce.cc DEPS) else() cc_library(enforce SRCS enforce.cc) endif() diff --git a/paddle/fluid/platform/dynload/CMakeLists.txt b/paddle/fluid/platform/dynload/CMakeLists.txt index cf2081b434..264b4ebf2c 100644 --- a/paddle/fluid/platform/dynload/CMakeLists.txt +++ b/paddle/fluid/platform/dynload/CMakeLists.txt @@ -1,4 +1,4 @@ cc_library(dynamic_loader SRCS dynamic_loader.cc DEPS glog gflags enforce) nv_library(dynload_cuda SRCS cublas.cc cudnn.cc curand.cc nccl.cc - DEPS dynamic_loader nccl) + DEPS dynamic_loader) cc_library(dynload_warpctc SRCS warpctc.cc DEPS dynamic_loader warpctc) diff --git a/paddle/fluid/platform/nccl_test.cu b/paddle/fluid/platform/nccl_test.cu index 7123035363..212ea8517e 100644 --- a/paddle/fluid/platform/nccl_test.cu +++ b/paddle/fluid/platform/nccl_test.cu @@ -89,6 +89,7 @@ TEST(NCCL, all_reduce) { VLOG(1) << "Invoking ncclAllReduce"; + dynload::ncclGroupStart(); for (int i = 0; i < dev_count; ++i) { VLOG(1) << "Invoking ncclAllReduce with device " << i; SetDeviceId(i); @@ -97,6 +98,7 @@ TEST(NCCL, all_reduce) { ncclSum, comms[i], data[i]->dev_ctx.stream())); VLOG(1) << "Invoked ncclAllReduce for device " << i; } + dynload::ncclGroupEnd(); VLOG(1) << "Invoked ncclAllReduce"; diff --git a/paddle/scripts/docker/build.sh b/paddle/scripts/docker/build.sh index 442a7ea883..56fa138786 100644 --- a/paddle/scripts/docker/build.sh +++ b/paddle/scripts/docker/build.sh @@ -34,6 +34,7 @@ function cmake_gen() { Configuring cmake in /paddle/build ... -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release} ${PYTHON_FLAGS} + -DWITH_DSO=ON -DWITH_DOC=OFF -DWITH_GPU=${WITH_GPU:-OFF} -DWITH_DISTRIBUTE=${WITH_DISTRIBUTE:-OFF} @@ -57,6 +58,7 @@ EOF cmake .. \ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release} \ ${PYTHON_FLAGS} \ + -DWITH_DSO=ON \ -DWITH_DOC=OFF \ -DWITH_GPU=${WITH_GPU:-OFF} \ -DWITH_DISTRIBUTE=${WITH_DISTRIBUTE:-OFF} \ @@ -171,7 +173,7 @@ EOF if [[ ${WITH_GPU} == "ON" ]]; then NCCL_DEPS="apt-get install -y libnccl-dev &&" else - NCCL_DEPS="" + NCCL_DEPS="" fi cat >> /paddle/build/Dockerfile <