Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/marian.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Junczys-Dowmunt <marcinjd@microsoft.com>2018-12-07 01:07:26 +0300
committerMarcin Junczys-Dowmunt <marcinjd@microsoft.com>2018-12-07 01:07:26 +0300
commitddf0c9ce0cdaab6ba64e59495415c866cf762af6 (patch)
tree0fdfb5514c4372b8c639fa8357156abc7dc6c390
parentd43ffce6080170e970befe5c565bd9d2c05c4e03 (diff)
add NCCL compilation to Marian and pass on CMake parameters to NCCL make file
-rw-r--r--CMakeLists.txt14
-rwxr-xr-xsrc/training/communicator_nccl.h6
2 files changed, 16 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c585b9f4..6534699a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -99,17 +99,27 @@ if(CUDA_FOUND)
endif()
if(USE_NCCL)
- set(NCCL_STATIC "${CMAKE_CURRENT_SOURCE_DIR}/src/3rd_party/nccl/build/lib/libnccl_static.a")
+ # define and set the include dir for the generated nccl.h header
+ set(NCCL_HEADER_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/nccl/include")
+ include_directories(${NCCL_HEADER_LOCATION})
+
+ # set the path for the generated static lib
+ set(NCCL_STATIC "${CMAKE_CURRENT_BINARY_DIR}/nccl/lib/libnccl_static.a")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_NCCL")
+
LIST(APPEND CUDA_NVCC_FLAGS -DUSE_NCCL; )
+ # sets output to build, passes cuda location from FindCUDA, sets c++ compiler to the same one CMake uses.
add_custom_command(OUTPUT ${NCCL_STATIC}
- COMMAND make
+ COMMAND make src.build BUILDDIR="${CMAKE_CURRENT_BINARY_DIR}/nccl" CUDA_HOME="${CUDA_TOOLKIT_ROOT_DIR}" CXX="${CMAKE_CXX_COMPILER}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/3rd_party/nccl")
add_custom_target(nccl_target DEPENDS ${NCCL_STATIC})
add_library(nccl STATIC IMPORTED)
set_target_properties(nccl PROPERTIES IMPORTED_LOCATION ${NCCL_STATIC})
add_dependencies(nccl nccl_target)
+
+ # adds the resulting files to be removed by `make clean`
+ set_directory_properties(PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/nccl)
endif(USE_NCCL)
else(CUDA_FOUND)
diff --git a/src/training/communicator_nccl.h b/src/training/communicator_nccl.h
index ccb473a0..ac6ffc71 100755
--- a/src/training/communicator_nccl.h
+++ b/src/training/communicator_nccl.h
@@ -4,8 +4,10 @@
#include "3rd_party/threadpool.h"
#include "tensors/gpu/cuda_helpers.h"
-#include "cuda_runtime.h"
-#include "nccl/build/include/nccl.h"
+#include "nccl.h"
+
+#include <cuda_runtime.h>
+
#if (NCCL_MAJOR<3 || NCCL_MINOR<2)
#define ncclGetVersion(pv) (*(pv) = (NCCL_MAJOR * 1000 + NCCL_MINOR * 100 + NCCL_PATCH))
#endif