Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEA] Add option to build faiss and treelite shared libs, inherit common dependencies from raft #4256

Merged
merged 96 commits into from
Jan 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
31c931b
add option to build faiss and treelite shared libs
trxcllnt Sep 30, 2021
1254657
simplify treelite targets linkage
trxcllnt Sep 30, 2021
0a4a006
add FAISS::FAISS to the list of global targets
trxcllnt Sep 30, 2021
7ce8aad
fix typo
trxcllnt Sep 30, 2021
b690f07
point to my raft fork
trxcllnt Sep 30, 2021
4502850
create a faiss-exports export-set
trxcllnt Sep 30, 2021
6435a6d
mark faiss to be found as part of resolving cuml-exports dependencies
trxcllnt Sep 30, 2021
77b596d
create faiss-exports export set
trxcllnt Sep 30, 2021
97072be
create faiss-exports export set
trxcllnt Sep 30, 2021
d0393a0
add a build export-set to go alongside the existing TreeliteTargets i…
trxcllnt Sep 30, 2021
73add83
modify and export the correct shared or static treelite targets
trxcllnt Oct 1, 2021
656901e
test without adding treelite targets to export set
trxcllnt Oct 1, 2021
25e6d32
what about this
trxcllnt Oct 1, 2021
33909b4
both
trxcllnt Oct 1, 2021
e93589f
I'll make my own then
trxcllnt Oct 1, 2021
e8d8c19
only modify the treelite targets for the library type we're using, ad…
trxcllnt Oct 1, 2021
788305d
only create treelite-exports if treelite_added is true
trxcllnt Oct 1, 2021
5b44a4a
Merge branch 'fix/build-shared-faiss' into fix/node-rapids-21.10
trxcllnt Oct 1, 2021
3c44eae
fix typo
trxcllnt Oct 1, 2021
80e929b
Merge branch 'fix/build-shared-faiss' into fix/node-rapids-21.10
trxcllnt Oct 1, 2021
b1f8e8b
always make treelite-exports export set
trxcllnt Oct 1, 2021
849215d
Merge branch 'fix/build-shared-faiss' into fix/node-rapids-21.10
trxcllnt Oct 1, 2021
a411c30
get faiss::faiss from raft
trxcllnt Oct 5, 2021
49a15fb
use fix/node-rapids-21.10 branch
trxcllnt Oct 5, 2021
19cfac1
Merge branch 'branch-21.10' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Oct 5, 2021
ea0745d
use rapidsai/raft again
trxcllnt Oct 5, 2021
8b6b89c
Merge branch 'branch-21.12' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Oct 5, 2021
662659b
use CUML_BRANCH_VERSION_raft
trxcllnt Oct 5, 2021
36ae29b
fix FORK
trxcllnt Oct 5, 2021
50529c6
uncomment CPM_DOWNLOAD_ALL logic
trxcllnt Oct 5, 2021
3b8de87
globalize non-prefixed treelite targets
trxcllnt Oct 6, 2021
eccb1cc
update rapids-cmake version
trxcllnt Oct 6, 2021
5d5cf97
use Treelite vs. treelite
trxcllnt Oct 6, 2021
8487b97
add namespaced treelite targets to GLOBAL_TARGETS
trxcllnt Oct 6, 2021
1b8426d
mark in cuml-exports install_export_set
trxcllnt Oct 6, 2021
b250ee4
remove redundant dependencies that raft provides, remove dead code
trxcllnt Oct 7, 2021
dbcdb1e
Merge branch 'branch-21.12' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Oct 7, 2021
212bf6c
remove DISABLE_FORCE_CLONE_RAFT workaround
trxcllnt Oct 7, 2021
ff4dbed
add options to build static faiss and treelite
trxcllnt Oct 12, 2021
6128872
switch to my fork to test in CI
trxcllnt Oct 13, 2021
21594c8
Merge branch 'branch-21.12' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Oct 14, 2021
0cb6416
Merge branch 'branch-21.12' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Oct 15, 2021
5a67fe7
Merge branch 'branch-21.12' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Oct 18, 2021
7cd5b95
accounting for hpp file name
divyegala Oct 19, 2021
aa4eaef
Merge branch 'branch-21.12' of github.com:rapidsai/cuml into imp-21.1…
divyegala Oct 26, 2021
b72e6a0
had forgotten to update some includes
divyegala Oct 26, 2021
67886ea
last leftover include file mistake
divyegala Oct 26, 2021
9d83989
removing rng impl include
divyegala Oct 26, 2021
91cc4bd
Merge branch 'branch-21.12' of github.com:rapidsai/cuml into imp-21.1…
divyegala Nov 3, 2021
5227137
adding testing label for cumlprims
divyegala Nov 3, 2021
e3365e1
more updates for testing label
divyegala Nov 3, 2021
350701f
adding missing labels
divyegala Nov 4, 2021
f0c80b3
updating gpu ci build script to use gpuci_mamba
divyegala Nov 5, 2021
1f15061
added one more testing label
divyegala Nov 5, 2021
949b8e7
Merge branch 'branch-21.12' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Nov 10, 2021
7af6340
Merge branch 'branch-21.12' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Nov 11, 2021
537f57d
Reverting RAFT to main
divyegala Nov 11, 2021
8c12c87
Merge branch 'branch-21.12' into imp-21.12-matrix_stats_random_detail
divyegala Nov 11, 2021
152dbdc
marking sparse hellinger pytest as xfail
divyegala Nov 11, 2021
59e2f54
removing testing label
divyegala Nov 12, 2021
17a25b4
unpinning libcumlprims from conda recipe
divyegala Nov 12, 2021
7f272f8
Merge branch 'imp-21.12-matrix_stats_random_detail' of github.com:div…
trxcllnt Nov 12, 2021
bbde5c1
Merge branch 'branch-21.12' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Nov 12, 2021
4e951af
Merge branch 'branch-22.02' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Nov 18, 2021
bc6f9ac
Merge branch 'branch-22.02' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Nov 20, 2021
a39c204
Merge branch 'branch-22.02' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Dec 1, 2021
72bcc15
use the optional faiss component when finding or adding raft
trxcllnt Dec 1, 2021
5e8df0d
test not forcing thrust to download because we get it from raft now
trxcllnt Dec 2, 2021
ff9890e
remove dead code
trxcllnt Dec 2, 2021
aa6c8ca
Merge branch 'branch-22.02' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Dec 15, 2021
e7d6d0f
Merge branch 'branch-22.02' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Jan 6, 2022
5d7db67
Merge branch 'fix/build-shared-faiss' of github.com:trxcllnt/cuml int…
trxcllnt Jan 6, 2022
d78de98
Merge branch 'branch-22.02' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Jan 11, 2022
6bede44
Merge branch 'branch-22.02' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Jan 13, 2022
cf9baeb
Merge branch 'branch-22.02' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Jan 13, 2022
c0bf0a1
switch to use Robert's RAFT branch
trxcllnt Jan 13, 2022
485116b
update copyright year
trxcllnt Jan 14, 2022
9cfec67
add get_gtest.cmake
trxcllnt Jan 14, 2022
17e74be
Merge branch 'branch-22.02' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Jan 17, 2022
ab1da25
add cuML C and C++ target names to export set global names list
trxcllnt Jan 17, 2022
c013847
don't default to building faiss and treelite statically
trxcllnt Jan 18, 2022
cf67333
Merge branch 'branch-22.02' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Jan 18, 2022
7343da5
Merge branch 'branch-22.02' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Jan 19, 2022
d265f15
Replace use of RMM provided CUDA bindings with CUDA Python
shwina Jan 20, 2022
6f46a37
No cudart prefix
shwina Jan 20, 2022
24cd93f
Copyright
shwina Jan 20, 2022
bf2a9a1
Merge branch 'branch-22.02' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Jan 20, 2022
58623bb
Missing import
shwina Jan 20, 2022
adc5641
style
shwina Jan 20, 2022
05e9c9f
Merge branch 'replace-rmm-cuda-bindings-with-cuda-python' of github.c…
trxcllnt Jan 20, 2022
d02ab56
Reverting some changes to cub device segmented reduce templates
cjnolet Jan 20, 2022
93147d8
add template parameter for Thrust v1.15.0's version of CUB
trxcllnt Jan 21, 2022
196b6d9
add versions.json to force Thrust v1.15.0
trxcllnt Jan 21, 2022
e1c6182
Attemping normal cub dir again
cjnolet Jan 21, 2022
7a09999
remove experimental include
trxcllnt Jan 21, 2022
9f39243
Merge branch 'branch-22.02' of github.com:rapidsai/cuml into fix/buil…
trxcllnt Jan 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 35 additions & 24 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright (c) 2019-2021, NVIDIA CORPORATION.
# Copyright (c) 2019-2022, NVIDIA CORPORATION.

# cuml build script

Expand All @@ -23,30 +23,32 @@ VALIDFLAGS="-v -g -n --allgpuarch --singlegpu --nolibcumltest --nvtx --show_depr
VALIDARGS="${VALIDTARGETS} ${VALIDFLAGS}"
HELP="$0 [<target> ...] [<flag> ...]
where <target> is:
clean - remove all existing build artifacts and configuration (start over)
libcuml - build the cuml C++ code only. Also builds the C-wrapper library
around the C++ code.
cuml - build the cuml Python package
cpp-mgtests - build libcuml mnmg tests. Builds MPI communicator, adding MPI as dependency.
prims - build the ml-prims tests
bench - build the libcuml C++ benchmark
prims-bench - build the ml-prims C++ benchmark
cppdocs - build the C++ API doxygen documentation
pydocs - build the general and Python API documentation
clean - remove all existing build artifacts and configuration (start over)
libcuml - build the cuml C++ code only. Also builds the C-wrapper library
around the C++ code.
cuml - build the cuml Python package
cpp-mgtests - build libcuml mnmg tests. Builds MPI communicator, adding MPI as dependency.
prims - build the ml-prims tests
bench - build the libcuml C++ benchmark
prims-bench - build the ml-prims C++ benchmark
cppdocs - build the C++ API doxygen documentation
pydocs - build the general and Python API documentation
and <flag> is:
-v - verbose build mode
-g - build for debug
-n - no install step
-h - print this text
--allgpuarch - build for all supported GPU architectures
--singlegpu - Build libcuml and cuml without multigpu components
--nolibcumltest - disable building libcuml C++ tests for a faster build
--nvtx - Enable nvtx for profiling support
--show_depr_warn - show cmake deprecation warnings
--codecov - Enable code coverage support by compiling with Cython linetracing
and profiling enabled (WARNING: Impacts performance)
--ccache - Use ccache to cache previous compilations
--nocloneraft - CMake will clone RAFT even if it is in the environment, use this flag to disable that behavior
-v - verbose build mode
-g - build for debug
-n - no install step
-h - print this text
--allgpuarch - build for all supported GPU architectures
--singlegpu - Build libcuml and cuml without multigpu components
--nolibcumltest - disable building libcuml C++ tests for a faster build
--nvtx - Enable nvtx for profiling support
--show_depr_warn - show cmake deprecation warnings
--codecov - Enable code coverage support by compiling with Cython linetracing
and profiling enabled (WARNING: Impacts performance)
--ccache - Use ccache to cache previous compilations
--nocloneraft - CMake will clone RAFT even if it is in the environment, use this flag to disable that behavior
--static-faiss - Force CMake to use the FAISS static libs, cloning and building them if necessary
--static-treelite - Force CMake to use the Treelite static libs, cloning and building them if necessary

default action (no args) is to build and install 'libcuml', 'cuml', and 'prims' targets only for the detected GPU arch

Expand Down Expand Up @@ -77,6 +79,7 @@ BUILD_CUML_STD_COMMS=ON
BUILD_CUML_TESTS=ON
BUILD_CUML_MG_TESTS=OFF
BUILD_STATIC_FAISS=OFF
BUILD_STATIC_TREELITE=OFF
CMAKE_LOG_LEVEL=WARNING
DISABLE_FORCE_CLONE_RAFT=OFF

Expand Down Expand Up @@ -194,6 +197,12 @@ while true; do
--nocloneraft )
DISABLE_FORCE_CLONE_RAFT=ON
;;
--static-faiss )
BUILD_STATIC_FAISS=ON
;;
--static-treelite )
BUILD_STATIC_TREELITE=ON
;;
--)
shift
break
Expand Down Expand Up @@ -245,6 +254,8 @@ if completeBuild || hasArg libcuml || hasArg prims || hasArg bench || hasArg pri
-DBUILD_CUML_TESTS=${BUILD_CUML_TESTS} \
-DBUILD_CUML_MPI_COMMS=${BUILD_CUML_MG_TESTS} \
-DBUILD_CUML_MG_TESTS=${BUILD_CUML_MG_TESTS} \
-DCUML_USE_FAISS_STATIC=${BUILD_STATIC_FAISS} \
-DCUML_USE_TREELITE_STATIC=${BUILD_STATIC_TREELITE} \
-DDISABLE_FORCE_CLONE_RAFT=${DISABLE_FORCE_CLONE_RAFT} \
-DNVTX=${NVTX} \
-DUSE_CCACHE=${CCACHE} \
Expand Down
65 changes: 34 additions & 31 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ option(CUDA_ENABLE_KERNEL_INFO "Enable kernel resource usage info" OFF)
option(CUDA_ENABLE_LINE_INFO "Enable lineinfo in nvcc" OFF)
option(DETECT_CONDA_ENV "Enable detection of conda environment for dependencies" ON)
option(DISABLE_DEPRECATION_WARNINGS "Disable depreaction warnings " ON)
option(DISABLE_FORCE_CLONE_RAFT "By default, CPM will clone RAFT even if it's already in the environment. Set to disable that behavior." OFF)
option(DISABLE_OPENMP "Disable OpenMP" OFF)
option(ENABLE_CUMLPRIMS_MG "Enable algorithms that use libcumlprims_mg" ON)
option(NVTX "Enable nvtx markers" OFF)
option(SINGLEGPU "Disable all mnmg components and comms libraries" OFF)
option(USE_CCACHE "Cache build artifacts with ccache" OFF)
option(CUML_USE_FAISS_STATIC "Build and statically link the FAISS library for nearest neighbors search on GPU" OFF)
option(CUML_USE_TREELITE_STATIC "Build and statically link the treelite library" OFF)

set(CUML_CPP_ALGORITHMS "ALL" CACHE STRING "Experimental: Choose which algorithms are built into libcuml++.so. Only 'FIL' and 'ALL' are supported right now.")
set_property(CACHE CUML_CPP_ALGORITHMS PROPERTY STRINGS "ALL" "FIL")
Expand Down Expand Up @@ -153,12 +154,12 @@ if(NOT BUILD_CUML_CPP_LIBRARY)
endif()

if(CUML_CPP_ALGORITHMS STREQUAL "ALL")
set(LINK_FAISS ON)
set(CUML_USE_RAFT_NN ON)
elseif(CUML_CPP_ALGORITHMS STREQUAL "FIL")
set(SINGLEGPU ON)
set(BUILD_CUML_C_LIBRARY OFF)
set(BUILD_CUML_EXAMPLES OFF)
set(LINK_FAISS OFF)
set(CUML_USE_RAFT_NN OFF)
endif()

# SingleGPU build disables cumlprims_mg and comms components
Expand Down Expand Up @@ -189,16 +190,9 @@ endif()
# add third party dependencies using CPM
rapids_cpm_init()

include(cmake/thirdparty/get_thrust.cmake)
include(cmake/thirdparty/get_rmm.cmake)

if(LINK_FAISS)
include(cmake/thirdparty/get_faiss.cmake)
endif()

include(cmake/thirdparty/get_raft.cmake)
include(cmake/thirdparty/get_treelite.cmake)
include(cmake/thirdparty/get_gputreeshap.cmake)
include(cmake/thirdparty/get_raft.cmake)

if(NOT SINGLEGPU)
include(cmake/thirdparty/get_nccl.cmake)
Expand All @@ -213,7 +207,7 @@ if(BUILD_CUML_TESTS OR BUILD_PRIMS_TESTS)
include(cmake/thirdparty/get_gtest.cmake)
endif()

if(BUILD_CUML_BENCH)
if(BUILD_CUML_BENCH OR BUILD_CUML_PRIMS_BENCH)
include(cmake/thirdparty/get_gbench.cmake)
endif()

Expand Down Expand Up @@ -388,22 +382,13 @@ if(BUILD_CUML_CPP_LIBRARY)

target_link_libraries(${CUML_CPP_TARGET}
PUBLIC
rmm::rmm
cuml::Thrust
raft::raft
raft::raft_nn
raft::raft_distance
raft::nn
raft::distance
PRIVATE
CUDA::cublas
CUDA::cufft
CUDA::curand
CUDA::cusolver
CUDA::cudart
CUDA::cusparse
${TREELITE_LIBS}
GPUTreeShap::GPUTreeShap
$<$<BOOL:${LINK_FAISS}>:FAISS::FAISS>
$<IF:$<BOOL:${Treelite_ADDED}>,treelite::treelite_static,treelite::treelite>
$<IF:$<BOOL:${Treelite_ADDED}>,treelite::treelite_runtime_static,treelite::treelite_runtime>
$<$<BOOL:${OpenMP_FOUND}>:OpenMP::OpenMP_CXX>
$<$<OR:$<BOOL:${BUILD_CUML_STD_COMMS}>,$<BOOL:${BUILD_CUML_MPI_COMMS}>>:NCCL::NCCL>
$<$<BOOL:${BUILD_CUML_MPI_COMMS}>:${MPI_CXX_LIBRARIES}>
Expand Down Expand Up @@ -448,8 +433,6 @@ if(BUILD_CUML_C_LIBRARY)
target_link_libraries(${CUML_C_TARGET}
PUBLIC
${CUML_CPP_TARGET}
PRIVATE
FAISS::FAISS
)

# ensure CUDA symbols aren't relocated to the middle of the debug build binaries
Expand Down Expand Up @@ -508,14 +491,34 @@ functions that share compatible APIs with other RAPIDS projects.

]=])

set(code_string
set(code_string )

if (TARGET treelite::treelite)
string(APPEND code_string
[=[
thrust_create_target(cuml::Thrust FROM_OPTIONS)
if (TARGET treelite::treelite AND (NOT TARGET treelite))
add_library(treelite ALIAS treelite::treelite)
endif()
if (TARGET treelite::treelite_runtime AND (NOT TARGET treelite_runtime))
add_library(treelite_runtime ALIAS treelite::treelite_runtime)
endif()
]=])
else()
string(APPEND code_string
[=[
if (TARGET treelite::treelite_static AND (NOT TARGET treelite_static))
add_library(treelite_static ALIAS treelite::treelite_static)
endif()
if (TARGET treelite::treelite_runtime_static AND (NOT TARGET treelite_runtime_static))
add_library(treelite_runtime_static ALIAS treelite::treelite_runtime_static)
endif()
]=])

rapids_export(INSTALL cuml
endif()

rapids_export(INSTALL cuml
EXPORT_SET cuml-exports
GLOBAL_TARGETS cuml
GLOBAL_TARGETS ${CUML_C_TARGET} ${CUML_CPP_TARGET}
NAMESPACE cuml::
DOCUMENTATION doc_string
FINAL_CODE_BLOCK code_string
Expand All @@ -526,7 +529,7 @@ thrust_create_target(cuml::Thrust FROM_OPTIONS)

rapids_export(BUILD cuml
EXPORT_SET cuml-exports
GLOBAL_TARGETS cuml
GLOBAL_TARGETS ${CUML_C_TARGET} ${CUML_CPP_TARGET}
NAMESPACE cuml::
DOCUMENTATION doc_string
FINAL_CODE_BLOCK code_string
Expand Down
19 changes: 8 additions & 11 deletions cpp/bench/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
# Copyright (c) 2019-2022, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,11 +44,10 @@ if(BUILD_CUML_BENCH)
PUBLIC
cuml::${CUML_CPP_TARGET}
benchmark::benchmark
${TREELITE_LIBS}
raft::raft
raft::raft_nn
raft::raft_distance
$<IF:$<BOOL:${Treelite_ADDED}>,treelite::treelite_static,treelite::treelite>
$<IF:$<BOOL:${Treelite_ADDED}>,treelite::treelite_runtime_static,treelite::treelite_runtime>
raft::nn
raft::distance
)

target_include_directories(${CUML_CPP_BENCH_TARGET}
Expand Down Expand Up @@ -85,14 +84,12 @@ if(BUILD_CUML_PRIMS_BENCH)

target_link_libraries(${PRIMS_BENCH_TARGET}
PUBLIC
cuml
CUDA::cublas
cuml::${CUML_CPP_TARGET}
benchmark::benchmark
${TREELITE_LIBS}
raft::raft
raft::raft_nn
raft::raft_distance
$<IF:$<BOOL:${Treelite_ADDED}>,treelite::treelite_static,treelite::treelite>
$<IF:$<BOOL:${Treelite_ADDED}>,treelite::treelite_runtime_static,treelite::treelite_runtime>
raft::nn
raft::distance
)

target_include_directories(${PRIMS_BENCH_TARGET}
Expand Down
53 changes: 0 additions & 53 deletions cpp/cmake/thirdparty/get_faiss.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion cpp/cmake/thirdparty/get_gtest.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2021, NVIDIA CORPORATION.
# Copyright (c) 2021-2022, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Loading