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

Update Python build to scikit-build #4818

Merged
merged 44 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c6a65e6
FEA added CMakeLists to python folders
dantegd Jul 14, 2022
d12eaeb
FIX Multiple cmake fixes
dantegd Jul 14, 2022
b92e40a
FIX Multiple small fixes
dantegd Jul 15, 2022
6a2b1d6
DBG Move files back to original structure
dantegd Jul 19, 2022
1a73eb9
FIX CMake fixes
dantegd Jul 19, 2022
5c74296
FIX Use find_raft
dantegd Jul 19, 2022
390c547
FIX Small pytests fixes
dantegd Jul 19, 2022
2a686e3
DBG Rename dask tests to accomodate for pytest
dantegd Jul 19, 2022
e700dcf
FEA Add singlegpu option to cmake files
dantegd Jul 20, 2022
8001205
FEA Initial build.sh update
dantegd Jul 20, 2022
6d5a7c0
FIX Typo
dantegd Jul 20, 2022
28cb356
FIX Remove accidentally deleted function
dantegd Jul 20, 2022
25e0b35
Merge pull request #5 from dantegd/dev-skbuild
dantegd Jul 20, 2022
7e5751d
FIX Copyright years
dantegd Jul 20, 2022
f0b8465
FIX PEP8 fixes
dantegd Jul 20, 2022
e70c697
Merge branch 'dev-skbuild' into fea-skbuild
dantegd Jul 20, 2022
c3b3d25
FIX Forgot to commit conda recipe
dantegd Jul 20, 2022
754c65d
Merge branch 'branch-22.08' into fea-skbuild
dantegd Jul 20, 2022
3e75c23
FIX Add v_measure to cmakelists
dantegd Jul 20, 2022
31d9be7
FIX Remove clean from libcuml conda recipe
dantegd Jul 22, 2022
9c581c1
DBG simplify find cuml codepath
dantegd Jul 25, 2022
21c3dc8
FIX Correct cumlprims linking
dantegd Jul 27, 2022
280e5d3
FIX cleanup
dantegd Jul 27, 2022
575ecd0
FIX Remove repeated line
dantegd Jul 27, 2022
d812b50
FIX Add missing prefixes
dantegd Jul 27, 2022
930a216
Merge pull request #6 from dantegd/dev-skbuild
dantegd Jul 27, 2022
9104828
FIX Remove straggler comment
dantegd Jul 27, 2022
13e9dbe
Merge branch 'dev-skbuild' into fea-skbuild
dantegd Jul 27, 2022
c60b971
FIX typo
dantegd Jul 27, 2022
4fb224f
FIX Various fixes
dantegd Jul 27, 2022
df63847
FIX Undo unintended change
dantegd Jul 27, 2022
d354cb3
DBG Add verbosity to cmake command
dantegd Jul 27, 2022
ae0c1b5
FIX Copyright year
dantegd Jul 27, 2022
dbcfbe7
FIX Remove pytest.ini path change
dantegd Jul 27, 2022
465b42c
UPD update-versions update for rap-cmake file
dantegd Jul 28, 2022
c44d532
Merge branch 'branch-22.08' into fea-skbuild
dantegd Jul 28, 2022
d1ea26e
FIX Review feedback
dantegd Jul 29, 2022
be8cf5c
FIX Totally did not add the single and multigpu linked libraries back…
dantegd Jul 29, 2022
3294065
Merge branch 'dev-skbuild' into fea-skbuild
dantegd Jul 29, 2022
c750028
FIX PEP8 fixes
dantegd Jul 29, 2022
3575e03
FIX Small fixes from review
dantegd Aug 1, 2022
d2e3862
FIX Redo update-version.sh change
dantegd Aug 1, 2022
3c17fdb
ENH Use cuml-python versions to compute get_raft variables
dantegd Aug 1, 2022
0d3274a
ENH Add python/cmakelists to update-versions
dantegd Aug 1, 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ log
dask-worker-space/
tmp/
.hypothesis
wheels/
_skbuild/

## files pickled in notebook when ran during python docstring generation
docs/source/*.model
Expand Down
12 changes: 8 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ if (( ${CLEAN} == 1 )); then
cd ${REPODIR}
fi

# Before

################################################################################
# Configure for building all C++ targets
Expand Down Expand Up @@ -283,11 +282,16 @@ fi

# Build and (optionally) install the cuml Python package
if completeBuild || hasArg cuml || hasArg pydocs; then
# Append `-DFIND_CUML_CPP=ON` to CUML_EXTRA_CMAKE_ARGS unless a user specified the option.
if [[ "${CUML_EXTRA_CMAKE_ARGS}" != *"DFIND_CUML_CPP"* ]]; then
CUML_EXTRA_CMAKE_ARGS="${CUML_EXTRA_CMAKE_ARGS} -DFIND_CUML_CPP=ON"
fi

cd ${REPODIR}/python

python setup.py build_ext --inplace -- -DCMAKE_LIBRARY_PATH=${LIBCUML_BUILD_DIR} -DCMAKE_MESSAGE_LOG_LEVEL=${CMAKE_LOG_LEVEL} ${CUML_EXTRA_CMAKE_ARGS} -- -j${PARALLEL_LEVEL:-1}
if [[ ${INSTALL_TARGET} != "" ]]; then
python setup.py build_ext -j${PARALLEL_LEVEL:-1} ${CUML_EXTRA_PYTHON_ARGS} --library-dir=${LIBCUML_BUILD_DIR} install --single-version-externally-managed --record=record.txt
else
python setup.py build_ext -j${PARALLEL_LEVEL:-1} ${CUML_EXTRA_PYTHON_ARGS} --library-dir=${LIBCUML_BUILD_DIR}
python setup.py install --single-version-externally-managed --record=record.txt -- -DCMAKE_LIBRARY_PATH=${LIBCUML_BUILD_DIR} -DCMAKE_MESSAGE_LOG_LEVEL=${CMAKE_LOG_LEVEL} ${CUML_EXTRA_CMAKE_ARGS} -- -j${PARALLEL_LEVEL:-1}
fi

if hasArg pydocs; then
Expand Down
4 changes: 2 additions & 2 deletions ci/gpu/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ else
gpuci_logger "Building and installing cuml"
export CONDA_BLD_DIR="$WORKSPACE/.conda-bld"
export VERSION_SUFFIX=""
gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} conda/recipes/cuml -c ${CONDA_ARTIFACT_PATH} --python=${PYTHON}
gpuci_mamba_retry install -c ${CONDA_ARTIFACT_PATH} -c ${CONDA_BLD_DIR} cuml
gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/cuml -c ${CONDA_ARTIFACT_PATH} --python=${PYTHON}
gpuci_mamba_retry install cuml -c "${CONDA_BLD_DIR}" -c "${CONDA_ARTIFACT_PATH}"

gpuci_logger "Install the main version of dask, distributed, and dask-glm"
set -x
Expand Down
5 changes: 4 additions & 1 deletion ci/release/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ function sed_runner() {
}

sed_runner 's/'"CUML VERSION .* LANGUAGES"'/'"CUML VERSION ${NEXT_FULL_TAG} LANGUAGES"'/g' cpp/CMakeLists.txt
dantegd marked this conversation as resolved.
Show resolved Hide resolved
sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' cpp/CMakeLists.txt
sed_runner 's/'"set(CUML_VERSION .*)"'/'"set(CUML_VERSION ${NEXT_FULL_TAG})"'/g' python/CMakeLists.txt
# rapids-cmake version
sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' fetch_rapids.cmake


# RTD update
sed_runner 's/version = .*/version = '"'${NEXT_SHORT_TAG}'"'/g' docs/source/conf.py
Expand Down
1 change: 1 addition & 0 deletions conda/environments/cuml_dev_cuda11.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies:
- rapids-build-env=22.08.*
- rapids-notebook-env=22.08.*
- rapids-doc-env=22.08.*
- scikit-build>=0.13.1
- cudf=22.08.*
- rmm=22.08.*
- libcumlprims=22.08.*
Expand Down
1 change: 1 addition & 0 deletions conda/environments/cuml_dev_cuda11.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies:
- rapids-build-env=22.08.*
- rapids-notebook-env=22.08.*
- rapids-doc-env=22.08.*
- scikit-build>=0.13.1
- cudf=22.08.*
- rmm=22.08.*
- libcumlprims=22.08.*
Expand Down
1 change: 1 addition & 0 deletions conda/environments/cuml_dev_cuda11.4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies:
- rapids-build-env=22.08.*
- rapids-notebook-env=22.08.*
- rapids-doc-env=22.08.*
- scikit-build>=0.13.1
- cudf=22.08.*
- rmm=22.08.*
- libcumlprims=22.08.*
Expand Down
1 change: 1 addition & 0 deletions conda/environments/cuml_dev_cuda11.5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies:
- rapids-build-env=22.08.*
- rapids-notebook-env=22.08.*
- rapids-doc-env=22.08.*
- scikit-build>=0.13.1
- cudf=22.08.*
- rmm=22.08.*
- libcumlprims=22.08.*
Expand Down
3 changes: 2 additions & 1 deletion conda/recipes/cuml/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# Copyright (c) 2018-2022, NVIDIA CORPORATION.

# This assumes the script is executed from the root of the repo directory
./build.sh cuml
./build.sh cuml -v
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 3 additions & 0 deletions conda/recipes/cuml/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ cxx_compiler_version:
cuda_compiler:
- nvcc

cmake_version:
- ">=3.20.1,!=3.23.0"

sysroot_version:
- "2.17"
3 changes: 2 additions & 1 deletion conda/recipes/cuml/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ build:

requirements:
build:
- cmake>=3.20.1,!=3.23.0
- cmake {{ cmake_version }}
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- {{ compiler('cuda') }} {{ cuda_version }}
- sysroot_{{ target_platform }} {{ sysroot_version }}
host:
- python x.x
- setuptools
- scikit-build>=0.13.1
- cython>=0.29,<0.30
- treelite=2.4.0
- cudf {{ minor_version }}
Expand Down
2 changes: 1 addition & 1 deletion conda/recipes/libcuml/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ if [ -n "$MACOSX_DEPLOYMENT_TARGET" ]; then
export MACOSX_DEPLOYMENT_TARGET=10.11
fi

./build.sh -n clean libcuml prims -v --allgpuarch
./build.sh -n libcuml prims -v --allgpuarch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a debug change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the clean target of build.sh ends up calling setup.py clean, which imports skbuild which is not part of the libcuml requirements. This seemed like the simplest change to fix that since clean doesn't really seem to be necessary for buulding the conda packages.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does skbuild need to be brought into libcuml? Shouldn't it only be needed by cuml?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is why we needed to remove clean here, so that skbuild is not needed by libcuml.

The alternative would be to have separate C++ clean and Python clean targets, because right now clean calls both C++ and setup.py clean, the latter of which does import skbuild...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this hasn't been an issue with other RAPIDS libs because their clean target in build.sh manually runs rm etc rather than invoking python setup.py clean. Any attempt to use setup.py will now require skbuild. Personally I'm not sure that there is a truly clean solution for this problem other than having separate clean targets for different components, but that's a broader change to be made across the various RAPIDS libs.

64 changes: 32 additions & 32 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#=============================================================================

cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR)
file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.08/RAPIDS.cmake
${CMAKE_BINARY_DIR}/RAPIDS.cmake)
include(${CMAKE_BINARY_DIR}/RAPIDS.cmake)

include(../fetch_rapids.cmake)

include(rapids-cmake)
include(rapids-cpm)
include(rapids-cuda)
Expand Down Expand Up @@ -72,36 +72,36 @@ 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)

message(VERBOSE "CUML: Building libcuml_c shared library. Contains the cuML C API: ${BUILD_CUML_C_LIBRARY}")
message(VERBOSE "CUML: Building libcuml shared library: ${BUILD_CUML_CPP_LIBRARY}")
message(VERBOSE "CUML: Building cuML algorithm tests: ${BUILD_CUML_TESTS}")
message(VERBOSE "CUML: Building cuML multigpu algorithm tests: ${BUILD_CUML_MG_TESTS}")
message(VERBOSE "CUML: Building ml-prims tests: ${BUILD_PRIMS_TESTS}")
message(VERBOSE "CUML: Building C++ API usage examples: ${BUILD_CUML_EXAMPLES}")
message(VERBOSE "CUML: Building cuML C++ benchmark tests: ${BUILD_CUML_BENCH}")
message(VERBOSE "CUML: Building ml-prims C++ benchmark tests: ${BUILD_CUML_PRIMS_BENCH}")
message(VERBOSE "CUML: Building the standard NCCL+UCX Communicator: ${BUILD_CUML_STD_COMMS}")
message(VERBOSE "CUML: Building the MPI+NCCL Communicator (used for testing): ${BUILD_CUML_MPI_COMMS}")
message(VERBOSE "CUML: Enabling detection of conda environment for dependencies: ${DETECT_CONDA_ENV}")
message(VERBOSE "CUML: Disabling OpenMP: ${DISABLE_OPENMP}")
message(VERBOSE "CUML: Enabling algorithms that use libcumlprims_mg: ${ENABLE_CUMLPRIMS_MG}")
message(VERBOSE "CUML: Enabling kernel resource usage info: ${KERNEL_INFO}")
message(VERBOSE "CUML: Enabling kernelinfo in nvcc: ${CUDA_ENABLE_KERNEL_INFO}")
message(VERBOSE "CUML: Enabling lineinfo in nvcc: ${CUDA_ENABLE_LINE_INFO}")
message(VERBOSE "CUML: Enabling nvtx markers: ${NVTX}")
message(VERBOSE "CUML: Disabling all mnmg components and comms libraries: ${SINGLEGPU}")
message(VERBOSE "CUML: Cache build artifacts with ccache: ${USE_CCACHE}")
message(VERBOSE "CUML: Build and statically link RAFT libraries: ${CUML_USE_RAFT_STATIC}")
message(VERBOSE "CUML: Build and statically link FAISS library: ${CUML_USE_FAISS_STATIC}")
message(VERBOSE "CUML: Build and statically link Treelite library: ${CUML_USE_TREELITE_STATIC}")
message(VERBOSE "CUML_CPP: Building libcuml_c shared library. Contains the cuML C API: ${BUILD_CUML_C_LIBRARY}")
message(VERBOSE "CUML_CPP: Building libcuml shared library: ${BUILD_CUML_CPP_LIBRARY}")
message(VERBOSE "CUML_CPP: Building cuML algorithm tests: ${BUILD_CUML_TESTS}")
message(VERBOSE "CUML_CPP: Building cuML multigpu algorithm tests: ${BUILD_CUML_MG_TESTS}")
message(VERBOSE "CUML_CPP: Building ml-prims tests: ${BUILD_PRIMS_TESTS}")
message(VERBOSE "CUML_CPP: Building C++ API usage examples: ${BUILD_CUML_EXAMPLES}")
message(VERBOSE "CUML_CPP: Building cuML C++ benchmark tests: ${BUILD_CUML_BENCH}")
message(VERBOSE "CUML_CPP: Building ml-prims C++ benchmark tests: ${BUILD_CUML_PRIMS_BENCH}")
message(VERBOSE "CUML_CPP: Building the standard NCCL+UCX Communicator: ${BUILD_CUML_STD_COMMS}")
message(VERBOSE "CUML_CPP: Building the MPI+NCCL Communicator (used for testing): ${BUILD_CUML_MPI_COMMS}")
message(VERBOSE "CUML_CPP: Enabling detection of conda environment for dependencies: ${DETECT_CONDA_ENV}")
message(VERBOSE "CUML_CPP: Disabling OpenMP: ${DISABLE_OPENMP}")
message(VERBOSE "CUML_CPP: Enabling algorithms that use libcumlprims_mg: ${ENABLE_CUMLPRIMS_MG}")
message(VERBOSE "CUML_CPP: Enabling kernel resource usage info: ${KERNEL_INFO}")
message(VERBOSE "CUML_CPP: Enabling kernelinfo in nvcc: ${CUDA_ENABLE_KERNEL_INFO}")
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: 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}")

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: Building libcuml++ with algoriths: '${CUML_ALGORITHMS}'.")
message(VERBOSE "CUML_CPP: Building libcuml++ with algoriths: '${CUML_ALGORITHMS}'.")

# Set RMM logging level
set(RMM_LOGGING_LEVEL "INFO" CACHE STRING "Choose the logging level.")
set_property(CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF")
message(VERBOSE "CUML: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'.")
message(VERBOSE "CUML_CPP: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'.")

##############################################################################
# - Target names -------------------------------------------------------------
Expand All @@ -121,7 +121,7 @@ set(PRIMS_BENCH_TARGET "prims_benchmark")
if(DETECT_CONDA_ENV)
rapids_cmake_support_conda_env( conda_env MODIFY_PREFIX_PATH )
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND DEFINED ENV{CONDA_PREFIX})
message(STATUS "CUML: No CMAKE_INSTALL_PREFIX argument detected, setting to: $ENV{CONDA_PREFIX}")
message(STATUS "CUML_CPP: No CMAKE_INSTALL_PREFIX argument detected, setting to: $ENV{CONDA_PREFIX}")
set(CMAKE_INSTALL_PREFIX "$ENV{CONDA_PREFIX}")
endif()
endif()
Expand All @@ -132,7 +132,7 @@ endif()
if (NOT DISABLE_OPENMP)
find_package(OpenMP)
if(OpenMP_FOUND)
message(STATUS "CUML: OpenMP found in ${OPENMP_INCLUDE_DIRS}")
message(STATUS "CUML_CPP: OpenMP found in ${OPENMP_INCLUDE_DIRS}")
endif()
endif()

Expand Down Expand Up @@ -170,8 +170,8 @@ endif()

# SingleGPU build disables cumlprims_mg and comms components
if(SINGLEGPU)
message(STATUS "Detected SINGLEGPU build option")
message(STATUS "Disabling Multi-GPU components and comms libraries")
message(STATUS "CUML_CPP: Detected SINGLEGPU build option")
message(STATUS "CUML_CPP: Disabling Multi-GPU components and comms libraries")
set(BUILD_CUML_MG_TESTS OFF)
set(BUILD_CUML_STD_COMMS OFF)
set(BUILD_CUML_MPI_COMMS OFF)
Expand All @@ -180,7 +180,7 @@ if(SINGLEGPU)
endif()

if(BUILD_CUML_MG_TESTS AND NOT SINGLEGPU)
message(STATUS "Detected BUILD_CUML_MG_TESTS set to ON. Enabling BUILD_CUML_MPI_COMMS")
message(STATUS "CUML_CPP: Detected BUILD_CUML_MG_TESTS set to ON. Enabling BUILD_CUML_MPI_COMMS")
set(BUILD_CUML_MPI_COMMS ON)
endif()

Expand Down
17 changes: 17 additions & 0 deletions fetch_rapids.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# =============================================================================
# Copyright (c) 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. 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.
# =============================================================================
file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.08/RAPIDS.cmake
${CMAKE_BINARY_DIR}/RAPIDS.cmake
)
include(${CMAKE_BINARY_DIR}/RAPIDS.cmake)
134 changes: 134 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# =============================================================================
# Copyright (c) 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. 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.20.1 FATAL_ERROR)

include(../fetch_rapids.cmake)

set(CUML_VERSION 22.08.00)
dantegd marked this conversation as resolved.
Show resolved Hide resolved

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
)

################################################################################
# - User Options --------------------------------------------------------------
option(FIND_CUML_CPP "Search for existing CUML C++ installations before defaulting to local files" OFF)
option(SINGLEGPU "Disable all mnmg components and comms libraries" 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}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW you can use the CMAKE_MESSAGE_CONTEXT variable to help set prefixes like CUML_PY for all messages within a scope.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

message(VERBOSE "CUML_PY: Disabling all mnmg components and comms libraries: ${SINGLEGPU}")

set(CUML_CPP_TARGET "cuml++")

################################################################################
# - Process User Options ------------------------------------------------------


# If the user requested it, we attempt to find cuml.
if(FIND_CUML_CPP)
include(rapids-cpm)
rapids_cpm_init()
include(rapids-cuda)
rapids_cuda_init_architectures(cuml-python)
enable_language(CUDA)

# variables used by get_raft.cmake, we can get rid of them when this is solved:
# https://github.com/rapidsai/rapids-cmake/issues/228
set(CUML_VERSION_MAJOR "${cuml-python_VERSION_MAJOR}")
set(CUML_VERSION_MINOR "${cuml-python_VERSION_MINOR}")
set(CUML_USE_RAFT_NN ON)
set(CUML_USE_RAFT_DIST ON)

# We need to call get_raft due to cuML asking for raft::nn and
# raft::distance targets
# see issue https://github.com/rapidsai/cuml/issues/4843
include(../cpp/cmake/thirdparty/get_raft.cmake)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We couldn't do away with these?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a bug. The FIL backend gets away with it because it doesn't use the nn and distance precompiled binaries, so will open an issue to look at it on a follow up

Copy link
Contributor

@vyasr vyasr Jul 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the raft targets be exported from the libcuml target? I see that they're part of the public link interface and raft::raft is part of the export sets. Should get_raft.cmake be using PKG_USE_RAFT_DIST, PKG_USE_RAFT_NN, and/or RAFT_COMPILE_LIBRARIES to decide whether or not to manually add raft::nn and/or raft::distance to the export sets as well? I'm thinking we need to use rapids_export_package manually on those targets here. CC @robertmaynard

Copy link
Member Author

@dantegd dantegd Jul 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually thinking about it for a bit, I think we just need to add raft::nn and raft::distance (conditionally) to

GLOBAL_TARGETS raft::raft
should be enough to properly add them to libcuml's exported targets, will try it locally. So I think there's no need for an additional rapids_export_package

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the raft::nn and raft::distance are made GLOBAL when they are brought in as well. ( if not they should be )

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems then there is a bug somewhere, without calling get_raft.cmake, or modifying get_raft.cmake in cuML, we run into the following issue:

CMake Error at /home/ursa/miniconda3/envs/skbuild4/lib/cmake/cuml/cuml-targets.cmake:56 (set_target_properties):
  The link interface of target "cuml::cuml++" contains:

    raft::nn

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  /home/ursa/miniconda3/envs/skbuild4/lib/cmake/cuml/cuml-config.cmake:77 (include)
  CMakeLists.txt:68 (find_package)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependency tracking in rapids-CMake doesn't understand COMPONENTs and therefore cuml is find raft but not enabling any components.
I think we can re call find package raft with the right components to unblock us.

Please file an issue on rapids-CMake about this


# We need to call get_treelite explicitly because we need the correct
# ${TREELITE_LIBS} definition for RF
include(../cpp/cmake/thirdparty/get_treelite.cmake)
find_package(cuml ${CUML_VERSION} REQUIRED)

else()
set(cuml_FOUND OFF)
endif()


if(NOT cuml_FOUND)
# TODO: This will not be necessary once we upgrade to CMake 3.22, which will pull in the required
# languages for the C++ project even if this project does not require those languges.
include(rapids-cuda)
rapids_cuda_init_architectures(cuml-python)
enable_language(CUDA)

# Since cuml only enables CUDA optionally, we need to manually include the file that
# rapids_cuda_init_architectures relies on `project` including.
include("${CMAKE_PROJECT_cuml-python_INCLUDE}")

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)
message(STATUS "installing packages")
add_subdirectory(../cpp cuml-cpp)

install(TARGETS ${CUML_CPP_TARGET} DESTINATION cuml/library)
endif()

set(cuml_sg_libraries cuml::${CUML_CPP_TARGET})

if(NOT SINGLEGPU)
include(../cpp/cmake/thirdparty/get_cumlprims_mg.cmake)
set(cuml_mg_libraries
cuml::${CUML_CPP_TARGET}
cumlprims_mg::cumlprims_mg
)
endif()

include(rapids-cython)
rapids_cython_init()

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/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)

Loading