Unverified Commit 66eb240d authored by nv-dlasalle's avatar nv-dlasalle Committed by GitHub
Browse files

[Bugfix] Include NCCL as a submodule (#2934)



* Add NCCL as a submodule

* Allow using third_party/nccl or system nccl

* Add nccl_external as a dependency

* Fix conditional
Co-authored-by: default avatarQuan (Andy) Gan <coin2028@hotmail.com>
parent 06b9ec2e
...@@ -32,3 +32,6 @@ ...@@ -32,3 +32,6 @@
[submodule "third_party/nanoflann"] [submodule "third_party/nanoflann"]
path = third_party/nanoflann path = third_party/nanoflann
url = https://github.com/jlblancoc/nanoflann url = https://github.com/jlblancoc/nanoflann
[submodule "third_party/nccl"]
path = third_party/nccl
url = https://github.com/nvidia/nccl
...@@ -23,6 +23,7 @@ endif() ...@@ -23,6 +23,7 @@ endif()
# and add set(OPTION VALUE) to override these build options. # and add set(OPTION VALUE) to override these build options.
# Alernatively, use cmake -DOPTION=VALUE through command-line. # Alernatively, use cmake -DOPTION=VALUE through command-line.
dgl_option(USE_CUDA "Build with CUDA" OFF) dgl_option(USE_CUDA "Build with CUDA" OFF)
dgl_option(USE_SYSTEM_NCCL "Build using system's NCCL library" OFF)
dgl_option(USE_OPENMP "Build with OpenMP" ON) dgl_option(USE_OPENMP "Build with OpenMP" ON)
dgl_option(USE_AVX "Build with AVX optimization" ON) dgl_option(USE_AVX "Build with AVX optimization" ON)
dgl_option(USE_FP16 "Build with fp16 support to enable mixed precision training" OFF) dgl_option(USE_FP16 "Build with fp16 support to enable mixed precision training" OFF)
...@@ -159,13 +160,21 @@ if(USE_CUDA) ...@@ -159,13 +160,21 @@ if(USE_CUDA)
dgl_config_cuda(DGL_CUDA_SRC) dgl_config_cuda(DGL_CUDA_SRC)
list(APPEND DGL_SRC ${DGL_CUDA_SRC}) list(APPEND DGL_SRC ${DGL_CUDA_SRC})
if (USE_SYSTEM_NCCL)
include(cmake/util/FindNccl.cmake) include(cmake/util/FindNccl.cmake)
else()
include(cmake/modules/NCCL.cmake)
endif()
include_directories(${NCCL_INCLUDE_DIR}) include_directories(${NCCL_INCLUDE_DIR})
list(APPEND DGL_LINKER_LIBS ${NCCL_LIBRARY}) list(APPEND DGL_LINKER_LIBS ${NCCL_LIBRARY})
endif(USE_CUDA) endif(USE_CUDA)
if(USE_CUDA) if(USE_CUDA)
cuda_add_library(dgl SHARED ${DGL_SRC}) cuda_add_library(dgl SHARED ${DGL_SRC})
if (NOT USE_SYSTEM_NCCL)
add_dependencies(dgl nccl_external)
endif()
else(USE_CUDA) else(USE_CUDA)
add_library(dgl SHARED ${DGL_SRC}) add_library(dgl SHARED ${DGL_SRC})
endif(USE_CUDA) endif(USE_CUDA)
......
include(ExternalProject)
# set path to submodule
set(NCCL_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/nccl")
# NCCL doesn't have CMAKE, so build externally
ExternalProject_Add(nccl_external
SOURCE_DIR ${PROJECT_SOURCE_DIR}/third_party/nccl
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ""
BUILD_COMMAND
env
make
"src.build"
"-j"
"BUILDDIR=${NCCL_BUILD_DIR}"
BUILD_BYPRODUCTS "${NCCL_BUILD_DIR}/lib/libnccl_static.a"
INSTALL_COMMAND ""
)
# set output variables
set(NCCL_FOUND TRUE)
set(NCCL_LIBRARY "${NCCL_BUILD_DIR}/lib/libnccl_static.a")
set(NCCL_INCLUDE_DIR "${NCCL_BUILD_DIR}/include")
Subproject commit 911d61f214d45c98df1ee8c0ac23c33fb94b63de
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment