forked from NVIDIA-Merlin/HugeCTR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
195 lines (167 loc) · 6.54 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#
# Copyright (c) 2020, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
cmake_minimum_required(VERSION 3.8)
project(HugeCTR LANGUAGES CXX CUDA)
option(ONLY_EMB_PLUGIN, "Only build embedding plugin" OFF)
if (ONLY_EMB_PLUGIN)
message("-- Please be noted that only embedding plugin will be built.")
include(${PROJECT_SOURCE_DIR}/cmake/EmbeddingPlugin.cmake)
return()
endif()
set(CMAKE_CXX_STANDARD 14)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
option(CLANGFORMAT "Setup clangformat target" OFF)
if(CLANGFORMAT)
include(ClangFormat)
file(GLOB_RECURSE HUGECTR_SRC
${PROJECT_SOURCE_DIR}/HugeCTR/*.hpp
${PROJECT_SOURCE_DIR}/HugeCTR/*.cpp
${PROJECT_SOURCE_DIR}/HugeCTR/*.cu
${PROJECT_SOURCE_DIR}/HugeCTR/*.cuh
${PROJECT_SOURCE_DIR}/utest/*.hpp
${PROJECT_SOURCE_DIR}/utest/*.cpp
${PROJECT_SOURCE_DIR}/utest/*.cu
${PROJECT_SOURCE_DIR}/utest/*.cuh
)
set(clangformat_srcs ${HUGECTR_SRC})
clangformat_setup("${clangformat_srcs}")
endif()
option(NCCL_A2A "NCCL all2all mode: use NCCL for all2all communication" ON)
if (NCCL_A2A)
message(STATUS "-- NCCL_A2A is ON")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNCCL_A2A")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNCCL_A2A")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DNCCL_A2A")
endif()
find_package(CUDA REQUIRED)
find_package(CUDNN REQUIRED)
find_package(NCCL REQUIRED)
find_package(OpenMP REQUIRED)
find_package(Threads)
option(ENABLE_MULTINODES "Enable multi-nodes training" OFF)
if(ENABLE_MULTINODES)
message(STATUS "Multi Node Enabled")
find_package(MPI)
find_package(UCX)
find_package(HWLOC)
endif()
set(CUDA_SEPARABLE_COMPILATION ON)
if (OPENMP_FOUND)
message(STATUS "OPENMP FOUND")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
set(JSON_BuildTests OFF CACHE INTERNAL "")
option(VAL_MODE "Validation mode: set determined mode for data reader and csv format for loss print" OFF)
if (VAL_MODE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVAL")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVAL")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DVAL")
endif()
# setting compiler flags
foreach(arch_name ${SM})
if (arch_name STREQUAL 80 OR
arch_name STREQUAL 75 OR
arch_name STREQUAL 70 OR
arch_name STREQUAL 61 OR
arch_name STREQUAL 60)
list(APPEND cuda_arch_list ${arch_name})
message(STATUS "-- Assign GPU architecture (sm=${arch_name})")
else()
message(FATAL_ERROR "-- Unknown or unsupported GPU architecture (set sm=70)")
endif()
endforeach()
list(LENGTH cuda_arch_list cuda_arch_list_length)
if(${cuda_arch_list_length} EQUAL 0)
list(APPEND cuda_arch_list "70")
endif()
list(REMOVE_DUPLICATES cuda_arch_list)
foreach(arch_name ${cuda_arch_list})
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -gencode arch=compute_${arch_name},code=sm_${arch_name}")
endforeach()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wno-unknown-pragmas")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -rdc=true -Xcompiler -Wall,-Werror,-Wno-error=cpp")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -Wall -Werror")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -Wall -Werror -Wno-unknown-pragmas")
set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -O0 -G -Xcompiler -Wall,-Werror,-Wno-error=cpp")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-extended-lambda --expt-relaxed-constexpr")
# setting output folder
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
configure_file(${PROJECT_SOURCE_DIR}/HugeCTR/include/config.hpp.in ${PROJECT_SOURCE_DIR}/HugeCTR/include/config.hpp)
# building
include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/test
${PROJECT_SOURCE_DIR}/HugeCTR/include
$ENV{CONDA_PREFIX}/include
$ENV{CONDA_PREFIX}/include/libcudf/libcudacxx
${CUDA_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/third_party/cutlass
${PROJECT_SOURCE_DIR}/third_party/cuml/cpp
${PROJECT_SOURCE_DIR}/third_party/cuml/cpp/include
${PROJECT_SOURCE_DIR}/third_party/cuml/cpp/src_prims
${PROJECT_SOURCE_DIR}/HugeCTR
${PROJECT_SOURCE_DIR}/HugeCTR/include
${PROJECT_SOURCE_DIR}/third_party
${PROJECT_SOURCE_DIR}/third_party/cub
${PROJECT_SOURCE_DIR}/third_party/googletest/googletest/include
${PROJECT_SOURCE_DIR}/third_party/json/single_include
${CUDNN_INC_PATHS}
${NCCL_INC_PATHS}
${HWLOC_INC_PATHS}
${UCX_INC_PATHS})
if(ENABLE_MULTINODES)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_MPI")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MPI")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DENABLE_MPI")
include_directories(${MPI_INCLUDE_PATH})
include_directories(${HWLOC_INC_PATHS})
include_directories(${UCX_INC_PATHS})
endif()
if(OPENMP_FOUND)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -fopenmp")
message(STATUS "add -fopenmp to compiler")
else()
message(FATAL_ERROR "without openmp the multi-node all2all will fail")
endif()
link_directories(
${CUDNN_LIB_PATHS}
${NCCL_LIB_PATHS}
${HWLOC_LIB_PATHS}
${UCX_LIB_PATHS}
$ENV{CONDA_PREFIX}/lib)
#setting python interface file install path
install(DIRECTORY ${CMAKE_BINARY_DIR}/lib DESTINATION /usr/local/hugectr)
#install inference header files
install(DIRECTORY ${PROJECT_SOURCE_DIR}/HugeCTR/include/inference DESTINATION /usr/local/hugectr/include)
add_subdirectory(third_party/json)
install(DIRECTORY ${CMAKE_BINARY_DIR}/bin DESTINATION /usr/local/hugectr)
option(ENABLE_INFERENCE "Enable Inference" OFF)
if(ENABLE_INFERENCE)
add_subdirectory(third_party/googletest)
add_subdirectory(HugeCTR/src/inference)
add_subdirectory(HugeCTR/src/cpu)
add_subdirectory(test/utest/inference)
else()
#setting binary files install path
add_subdirectory(HugeCTR/src)
add_subdirectory(third_party/googletest)
add_subdirectory(test/utest)
add_subdirectory(tools)
endif()