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] Statically link all CUDA toolkit libraries #4881

Merged
merged 4 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
19 changes: 18 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ 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(CUDA_STATIC_RUNTIME "Statically link the CUDA toolkit runtime and libraries" OFF)
option(CUML_USE_RAFT_STATIC "Build and statically link the RAFT libraries" 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)
Expand All @@ -91,6 +92,7 @@ message(VERBOSE "CUML_CPP: Enabling lineinfo in nvcc: ${CUDA_ENABLE_LINE_INFO}")
message(VERBOSE "CUML_CPP: Enabling nvtx markers: ${NVTX}")
message(VERBOSE "CUML_CPP: Disabling all mnmg components and comms libraries: ${SINGLEGPU}")
message(VERBOSE "CUML_CPP: Cache build artifacts with ccache: ${USE_CCACHE}")
message(VERBOSE "CUML_CPP: Statically link the CUDA toolkit runtime and libraries: ${CUDA_STATIC_RUNTIME}")
message(VERBOSE "CUML_CPP: Build and statically link RAFT libraries: ${CUML_USE_RAFT_STATIC}")
message(VERBOSE "CUML_CPP: Build and statically link FAISS library: ${CUML_USE_FAISS_STATIC}")
message(VERBOSE "CUML_CPP: Build and statically link Treelite library: ${CUML_USE_TREELITE_STATIC}")
Expand Down Expand Up @@ -129,13 +131,28 @@ endif()
##############################################################################
# - compiler options ---------------------------------------------------------

set(_ctk_static_suffix "")
if(CUDA_STATIC_RUNTIME)
# If we're statically linking CTK cuBLAS,
# we also want to statically link BLAS
set(BLA_STATIC ON)
set(_ctk_static_suffix "_static")
# Control legacy FindCUDA.cmake behavior too
# Remove this after we push it into rapids-cmake:
# https://github.com/rapidsai/rapids-cmake/pull/259
set(CUDA_USE_STATIC_CUDA_RUNTIME ON)
endif()

if (NOT DISABLE_OPENMP)
find_package(OpenMP)
if(OpenMP_FOUND)
message(STATUS "CUML_CPP: OpenMP found in ${OPENMP_INCLUDE_DIRS}")
endif()
endif()

# CUDA runtime
rapids_cuda_init_runtime(USE_STATIC ${CUDA_STATIC_RUNTIME})

# * find CUDAToolkit package
# * determine GPU architectures
# * enable the CMake CUDA language
Expand Down Expand Up @@ -522,7 +539,7 @@ if(BUILD_CUML_CPP_LIBRARY)
$<$<BOOL:${CUML_USE_RAFT_NN}>:raft::nn>
$<$<BOOL:${CUML_USE_RAFT_DIST}>:raft::distance>
PRIVATE
$<$<BOOL:${LINK_CUFFT}>:CUDA::cufft>
$<$<BOOL:${LINK_CUFFT}>:CUDA::cufft${_ctk_static_suffix}>
${TREELITE_LIBS}
$<$<BOOL:${treeshap_algo}>:GPUTreeShap::GPUTreeShap>
${OpenMP_CXX_LIB_NAMES}
Expand Down
2 changes: 1 addition & 1 deletion cpp/examples/symreg/CMakeLists_standalone.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ add_executable(symreg_example symreg_example.cpp)
set_target_properties(symreg_example PROPERTIES LINKER_LANGUAGE "CUDA")

# Link cuml and cudart
target_link_libraries(symreg_example cuml::cuml++ CUDA::cudart)
target_link_libraries(symreg_example cuml::cuml++)
12 changes: 6 additions & 6 deletions cpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ function(ConfigureTest)
PRIVATE
${CUML_CPP_TARGET}
$<$<BOOL:BUILD_CUML_C_LIBRARY>:${CUML_C_TARGET}>
CUDA::cublas
CUDA::curand
CUDA::cusolver
CUDA::cudart
CUDA::cusparse
$<$<BOOL:${LINK_CUFFT}>:CUDA::cufft>
CUDA::cublas${_ctk_static_suffix}
CUDA::curand${_ctk_static_suffix}
CUDA::cusolver${_ctk_static_suffix}
CUDA::cudart${_ctk_static_suffix}
CUDA::cusparse${_ctk_static_suffix}
$<$<BOOL:${LINK_CUFFT}>:CUDA::cufft${_ctk_static_suffix}>
rmm::rmm
raft::raft
$<$<BOOL:${CUML_USE_RAFT_NN}>:raft::nn>
Expand Down