-
Notifications
You must be signed in to change notification settings - Fork 540
/
CMakeLists.txt
163 lines (133 loc) · 5.67 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
# =============================================================================
# Copyright (c) 2022-2023 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.26.4 FATAL_ERROR)
include(../fetch_rapids.cmake)
set(CUML_VERSION 23.08.00)
# We always need CUDA for cuML because the raft dependency brings in a
# header-only cuco dependency that enables CUDA unconditionally.
include(rapids-cuda)
rapids_cuda_init_architectures(cuml-python)
project(
cuml-python
VERSION ${CUML_VERSION}
LANGUAGES # TODO: Building Python extension modules via the python_extension_module requires the C
# language to be enabled here. The test project that is built in scikit-build to verify
# various linking options for the python library is hardcoded to build with C, so until
# that is fixed we need to keep C.
C CXX CUDA
)
################################################################################
# - User Options --------------------------------------------------------------
option(CUML_UNIVERSAL "Build all cuML Python components." ON)
option(CUML_CPU "Build only cuML CPU Python components." OFF)
option(CUML_GPU "Build only cuML GPU Python components. Not supported yet, defaulting to CUML_UNIVERSAL" OFF)
option(FIND_CUML_CPP "Search for existing CUML C++ installations before defaulting to local files" OFF)
option(CUML_BUILD_WHEELS "Whether this build is generating a Python wheel." OFF)
option(SINGLEGPU "Disable all mnmg components and comms libraries" OFF)
set(CUML_RAFT_CLONE_ON_PIN OFF)
# todo: use CMAKE_MESSAGE_CONTEXT for prefix for logging.
# https://github.com/rapidsai/cuml/issues/4843
message(VERBOSE "CUML_PY: Searching for existing CUML C++ installations before defaulting to local files: ${FIND_CUML_CPP}")
message(VERBOSE "CUML_PY: Disabling all mnmg components and comms libraries: ${SINGLEGPU}")
set(CUML_ALGORITHMS "ALL" CACHE STRING "Experimental: Choose which algorithms are built into libcuml++.so. Can specify individual algorithms or groups in a semicolon-separated list.")
message(VERBOSE "CUML_PY: Building cuML with algorithms: '${CUML_ALGORITHMS}'.")
set(CUML_CPP_TARGET "cuml++")
set(CUML_CPP_SRC "../cpp")
################################################################################
# - Process User Options ------------------------------------------------------
# If the user requested it, we attempt to find cuml.
if(FIND_CUML_CPP)
# We need to call get_treelite explicitly because we need the correct
# ${TREELITE_LIBS} definition for RF
include(rapids-cpm)
include(rapids-export)
rapids_cpm_init()
include(../cpp/cmake/thirdparty/get_treelite.cmake)
find_package(cuml ${CUML_VERSION} REQUIRED)
else()
set(cuml_FOUND OFF)
endif()
include(rapids-cython)
if(CUML_BUILD_WHEELS)
set(CUML_PYTHON_TREELITE_TARGET treelite::treelite_static)
else()
set(CUML_PYTHON_TREELITE_TARGET treelite::treelite)
endif()
if(NOT cuml_FOUND)
set(BUILD_CUML_TESTS OFF)
set(BUILD_PRIMS_TESTS OFF)
set(BUILD_CUML_C_LIBRARY OFF)
set(BUILD_CUML_EXAMPLES OFF)
set(BUILD_CUML_BENCH OFF)
set(BUILD_CUML_PRIMS_BENCH OFF)
set(CUML_EXPORT_TREELITE_LINKAGE ON)
set(_exclude_from_all "")
if(CUML_BUILD_WHEELS)
# Statically link dependencies if building wheels
set(CUDA_STATIC_RUNTIME ON)
set(CUML_USE_RAFT_STATIC ON)
set(CUML_USE_FAISS_STATIC ON)
set(CUML_USE_TREELITE_STATIC ON)
set(CUML_USE_CUMLPRIMS_MG_STATIC ON)
# Don't install the static libs into wheels
set(CUML_EXCLUDE_RAFT_FROM_ALL ON)
set(RAFT_EXCLUDE_FAISS_FROM_ALL ON)
set(CUML_EXCLUDE_TREELITE_FROM_ALL ON)
set(CUML_EXCLUDE_CUMLPRIMS_MG_FROM_ALL ON)
# Don't install the cuML C++ targets into wheels
set(_exclude_from_all EXCLUDE_FROM_ALL)
endif()
add_subdirectory(../cpp cuml-cpp ${_exclude_from_all})
set(cython_lib_dir cuml)
install(TARGETS ${CUML_CPP_TARGET} DESTINATION ${cython_lib_dir})
endif()
if(CUML_CPU)
set(CUML_UNIVERSAL OFF)
set(SINGLEGPU ON)
set(CUML_ALGORITHMS "linearregression")
endif()
set(cuml_sg_libraries cuml::${CUML_CPP_TARGET})
set(cuml_mg_libraries cuml::${CUML_CPP_TARGET})
if(NOT SINGLEGPU)
include("${CUML_CPP_SRC}/cmake/thirdparty/get_cumlprims_mg.cmake")
set(cuml_mg_libraries
cuml::${CUML_CPP_TARGET}
cumlprims_mg::cumlprims_mg
)
endif()
rapids_cython_init()
include(cmake/ConfigureAlgorithmsHelpers.cmake)
add_subdirectory(cuml/common)
add_subdirectory(cuml/internals)
add_subdirectory(cuml/cluster)
add_subdirectory(cuml/datasets)
add_subdirectory(cuml/decomposition)
add_subdirectory(cuml/ensemble)
add_subdirectory(cuml/explainer)
add_subdirectory(cuml/experimental/fil)
add_subdirectory(cuml/fil)
add_subdirectory(cuml/kernel_ridge)
add_subdirectory(cuml/linear_model)
add_subdirectory(cuml/manifold)
add_subdirectory(cuml/metrics)
add_subdirectory(cuml/metrics/cluster)
add_subdirectory(cuml/neighbors)
add_subdirectory(cuml/random_projection)
add_subdirectory(cuml/solvers)
add_subdirectory(cuml/svm)
add_subdirectory(cuml/tsa)
add_subdirectory(cuml/experimental/linear_model)
if(DEFINED cython_lib_dir)
rapids_cython_add_rpath_entries(TARGET cuml PATHS "${cython_lib_dir}")
endif()