diff --git a/build.sh b/build.sh index bdaa607691..d0eebbd010 100755 --- a/build.sh +++ b/build.sh @@ -18,7 +18,7 @@ ARGS=$* # script, and that this script resides in the repo dir! REPODIR=$(cd $(dirname $0); pwd) -VALIDARGS="clean libraft pyraft pylibraft docs tests bench clean -v -g --install --compile-libs --compile-nn --compile-dist --allgpuarch --no-nvtx --show_depr_warn -h --buildfaiss --minimal-deps" +VALIDARGS="clean libraft pyraft pylibraft docs tests bench clean -v -g --install --compile-libs --compile-nn --compile-dist --allgpuarch --sccache --no-nvtx --show_depr_warn -h --buildfaiss --minimal-deps" HELP="$0 [ ...] [ ...] [--cmake-args=\"\"] where is: clean - remove all existing build artifacts and configuration (start over) @@ -33,6 +33,7 @@ HELP="$0 [ ...] [ ...] [--cmake-args=\"\"] and is: -v - verbose build mode -g - build for debug + --sccache - enable sccache --compile-libs - compile shared libraries for all components --compile-nn - compile shared library for nn component --compile-dist - compile shared library for distance component @@ -68,6 +69,7 @@ ENABLE_NN_DEPENDENCIES=OFF ENABLE_thrust_DEPENDENCY=ON +SCCACHE_ARGS="" NVTX=ON CLEAN=0 UNINSTALL=0 @@ -132,6 +134,10 @@ if hasArg --install; then INSTALL_TARGET="install" fi +if hasArg --sccache; then + SCCACHE_ARGS="-DCMAKE_CUDA_COMPILER_LAUNCHER=sccache -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache" +fi + if hasArg --minimal-deps; then ENABLE_thrust_DEPENDENCY=OFF fi @@ -165,6 +171,7 @@ fi if hasArg tests || (( ${NUMARGS} == 0 )); then BUILD_TESTS=ON + COMPILE_DIST_LIBRARY=ON ENABLE_NN_DEPENDENCIES=ON COMPILE_NN_LIBRARY=ON CMAKE_TARGET="${CMAKE_TARGET};test_raft" @@ -250,6 +257,7 @@ if (( ${NUMARGS} == 0 )) || hasArg libraft || hasArg docs || hasArg tests || has -DRAFT_COMPILE_DIST_LIBRARY=${COMPILE_DIST_LIBRARY} \ -DRAFT_USE_FAISS_STATIC=${BUILD_STATIC_FAISS} \ -DRAFT_ENABLE_thrust_DEPENDENCY=${ENABLE_thrust_DEPENDENCY} \ + ${SCCACHE_ARGS} \ ${EXTRA_CMAKE_ARGS} if [[ ${CMAKE_TARGET} != "" ]]; then diff --git a/ci/cpu/build.sh b/ci/cpu/build.sh index e8e6c6535c..d7bc122f92 100755 --- a/ci/cpu/build.sh +++ b/ci/cpu/build.sh @@ -5,6 +5,10 @@ ######################################### set -e +export SCCACHE_S3_KEY_PREFIX="libraft-$(uname -m)" +export SCCACHE_BUCKET="rapids-sccache" +export SCCACHE_REGION="us-west-2" +export SCCACHE_IDLE_TIMEOUT="32768" # Set path and build parallel level # openmpi dir is required on CentOS for finding MPI libs from cmake if [[ -e /etc/os-release ]] && (grep -qi centos /etc/os-release); then diff --git a/ci/cpu/prebuild.sh b/ci/cpu/prebuild.sh index 0364394423..ea12bf8b35 100755 --- a/ci/cpu/prebuild.sh +++ b/ci/cpu/prebuild.sh @@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +export UPLOAD_RAFT=1 +export UPLOAD_LIBRAFT=1 + if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then #If project flash is not activate, always build both export BUILD_RAFT=1 export BUILD_LIBRAFT=1 fi - -export UPLOAD_LIBRAFT=1 diff --git a/ci/cpu/upload.sh b/ci/cpu/upload.sh index dfd6ea3986..305a0eb861 100755 --- a/ci/cpu/upload.sh +++ b/ci/cpu/upload.sh @@ -37,7 +37,7 @@ if [[ "$BUILD_LIBRAFT" == "1" && "$UPLOAD_LIBRAFT" == "1" ]]; then gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing --no-progress ${LIBRAFT_FILES} fi -if [[ "$BUILD_RAFT" == "1" ]]; then +if [[ "$BUILD_RAFT" == "1" && "$UPLOAD_RAFT" == "1" ]]; then PYRAFT_FILE=$(conda build --no-build-id --croot ${CONDA_BLD_DIR} -c ${CONDA_LOCAL_CHANNEL} conda/recipes/pyraft --python=$PYTHON --output) PYLIBRAFT_FILE=$(conda build --no-build-id --croot ${CONDA_BLD_DIR} -c ${CONDA_LOCAL_CHANNEL} conda/recipes/pylibraft --python=$PYTHON --output) test -e ${PYRAFT_FILE} diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 79521a9969..6c5ffb51f6 100644 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -1,4 +1,6 @@ #!/bin/bash + + # Copyright (c) 2020-2022, NVIDIA CORPORATION. ######################################### # RAFT GPU build and test script for CI # @@ -17,12 +19,14 @@ function hasArg { export PATH=/opt/conda/bin:/usr/local/cuda/bin:$PATH export PARALLEL_LEVEL=${PARALLEL_LEVEL:-8} export CUDA_REL=${CUDA_VERSION%.*} +CONDA_ARTIFACT_PATH=${WORKSPACE}/ci/artifacts/raft/cpu/.conda-bld/ # notice there is no `linux-64` here + # Set home to the job's workspace -export HOME="$WORKSPACE" +export HOME=$WORKSPACE # Parse git describe -cd "$WORKSPACE" +cd $WORKSPACE export GIT_DESCRIBE_TAG=`git describe --tags` export MINOR_VERSION=`echo $GIT_DESCRIBE_TAG | grep -o -E '([0-9]+\.[0-9]+)'` unset GIT_DESCRIBE_TAG @@ -46,13 +50,7 @@ conda activate rapids # Install pre-built conda packages from previous CI step gpuci_logger "Install libraft conda packages from CPU job" -CONDA_ARTIFACT_PATH="$WORKSPACE/ci/artifacts/raft/cpu/.conda-bld/" # notice there is no `linux-64` here -gpuci_mamba_retry install -c "${CONDA_ARTIFACT_PATH}" libraft-headers libraft-distance libraft-nn libraft-tests - -gpuci_logger "Check compiler versions" -python --version -$CC --version -$CXX --version +gpuci_mamba_retry install -y -c "${CONDA_ARTIFACT_PATH}" libraft-headers libraft-distance libraft-nn gpuci_logger "Check conda environment" conda info @@ -63,12 +61,24 @@ conda list --show-channel-urls # BUILD - Build RAFT tests ################################################################################ +gpuci_logger "Adding ${CONDA_PREFIX}/lib to LD_LIBRARY_PATH" + +export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH + +#gpuci_logger "Build C++ and Python targets" +## These should link against the existing shared libs +#if hasArg --skip-tests; then +# "$WORKSPACE/build.sh" libraft -v +#else +# "$WORKSPACE/build.sh" libraft tests -v +#fi + gpuci_logger "Build and install Python targets" CONDA_BLD_DIR="$WORKSPACE/.conda-bld" gpuci_mamba_retry install boa gpuci_conda_retry mambabuild --no-build-id --croot "${CONDA_BLD_DIR}" conda/recipes/pyraft -c "${CONDA_ARTIFACT_PATH}" --python="${PYTHON}" gpuci_conda_retry mambabuild --no-build-id --croot "${CONDA_BLD_DIR}" conda/recipes/pylibraft -c "${CONDA_ARTIFACT_PATH}" --python="${PYTHON}" -gpuci_mamba_retry install -c "${CONDA_BLD_DIR}" -c "${CONDA_ARTIFACT_PATH}" pyraft pylibraft +gpuci_mamba_retry install -y -c "${CONDA_BLD_DIR}" -c "${CONDA_ARTIFACT_PATH}" pyraft pylibraft gpuci_logger "sccache stats" sccache --show-stats @@ -92,9 +102,17 @@ set +x gpuci_logger "Check GPU usage" nvidia-smi -gpuci_logger "GoogleTest for raft" -cd "$WORKSPACE" -GTEST_OUTPUT="xml:$WORKSPACE/test-results/raft_cpp/" "$CONDA_PREFIX/bin/libraft/gtests/test_raft" +if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then + gpuci_logger "GoogleTest for raft" + set -x + cd $WORKSPACE/cpp/build + GTEST_OUTPUT="xml:${WORKSPACE}/test-results/raft_cpp/" ./test_raft +else + # Install pre-built conda packages from previous CI step + gpuci_logger "Install libraft conda packages from CPU job" + gpuci_mamba_retry install -y -c "${CONDA_ARTIFACT_PATH}" libraft-tests + GTEST_OUTPUT="xml:${WORKSPACE}/test-results/raft_cpp/" $CONDA_PREFIX/bin/libraft/gtests/test_raft +fi gpuci_logger "Python pytest for pyraft" cd "$WORKSPACE/python/raft/raft/test" @@ -104,6 +122,7 @@ gpuci_logger "Python pytest for pylibraft" cd "$WORKSPACE/python/pylibraft/pylibraft/test" python -m pytest --cache-clear --junitxml="$WORKSPACE/junit-pylibraft.xml" -v -s + if [ "$(arch)" = "x86_64" ]; then gpuci_logger "Building docs" gpuci_mamba_retry install "rapids-doc-env=${MINOR_VERSION}.*" diff --git a/conda/recipes/libraft/build_libraft_distance.sh b/conda/recipes/libraft/build_libraft_distance.sh index 35a669d6df..8c44584719 100644 --- a/conda/recipes/libraft/build_libraft_distance.sh +++ b/conda/recipes/libraft/build_libraft_distance.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash # Copyright (c) 2022, NVIDIA CORPORATION. -./build.sh libraft --install -v --allgpuarch --compile-dist --no-nvtx +./build.sh libraft --install -v --allgpuarch --compile-dist --sccache --no-nvtx diff --git a/conda/recipes/libraft/build_libraft_headers.sh b/conda/recipes/libraft/build_libraft_headers.sh index 02ef674787..0176dac2f6 100644 --- a/conda/recipes/libraft/build_libraft_headers.sh +++ b/conda/recipes/libraft/build_libraft_headers.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash # Copyright (c) 2022, NVIDIA CORPORATION. -./build.sh libraft --install -v --allgpuarch --no-nvtx +./build.sh libraft --install -v --allgpuarch --sccache --no-nvtx diff --git a/conda/recipes/libraft/build_libraft_nn.sh b/conda/recipes/libraft/build_libraft_nn.sh index caa643a356..44e9279315 100644 --- a/conda/recipes/libraft/build_libraft_nn.sh +++ b/conda/recipes/libraft/build_libraft_nn.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash # Copyright (c) 2022, NVIDIA CORPORATION. -./build.sh libraft --install -v --allgpuarch --compile-nn --no-nvtx +./build.sh libraft --install -v --allgpuarch --sccache --compile-nn --no-nvtx diff --git a/conda/recipes/libraft/build_libraft_tests.sh b/conda/recipes/libraft/build_libraft_tests.sh index 040a2f8b8c..4e101f541a 100644 --- a/conda/recipes/libraft/build_libraft_tests.sh +++ b/conda/recipes/libraft/build_libraft_tests.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash # Copyright (c) 2022, NVIDIA CORPORATION. -./build.sh tests bench -v --allgpuarch --no-nvtx +./build.sh tests bench -v --allgpuarch --sccache --no-nvtx cmake --install cpp/build --component testing diff --git a/conda/recipes/libraft/conda_build_config.yaml b/conda/recipes/libraft/conda_build_config.yaml index 874335c231..bed95d14b3 100644 --- a/conda/recipes/libraft/conda_build_config.yaml +++ b/conda/recipes/libraft/conda_build_config.yaml @@ -1,3 +1,15 @@ +c_compiler_version: + - 9 + +cxx_compiler_version: + - 9 + +cuda_compiler: + - nvcc + +sysroot_version: + - "2.17" + cmake_version: - ">=3.20.1,!=3.23.0" @@ -10,5 +22,8 @@ gtest_version: libcusolver_version: - ">=11.2.1" +libcusparse_version: + - ">=11.5.0" + libfaiss_version: - "1.7.0 *_cuda" diff --git a/conda/recipes/libraft/meta.yaml b/conda/recipes/libraft/meta.yaml index 5321cf0187..348ae66645 100644 --- a/conda/recipes/libraft/meta.yaml +++ b/conda/recipes/libraft/meta.yaml @@ -15,35 +15,38 @@ package: source: git_url: ../../.. +build: + script_env: + - PARALLEL_LEVEL + - VERSION_SUFFIX + - PROJECT_FLASH + - CMAKE_GENERATOR + - SCCACHE_S3_KEY_PREFIX=libraft-aarch64 # [aarch64] + - SCCACHE_S3_KEY_PREFIX=libraft-linux64 # [linux64] + - SCCACHE_BUCKET=rapids-sccache + - SCCACHE_REGION=us-west-2 + - SCCACHE_IDLE_TIMEOUT=32768 + outputs: - name: libraft-headers version: {{ version }} script: build_libraft_headers.sh build: - script_env: &script_env - - CC - - CXX - - CUDAHOSTCXX - - PARALLEL_LEVEL - - VERSION_SUFFIX - - PROJECT_FLASH - - CMAKE_GENERATOR - - CMAKE_C_COMPILER_LAUNCHER - - CMAKE_CXX_COMPILER_LAUNCHER - - CMAKE_CUDA_COMPILER_LAUNCHER - - SCCACHE_S3_KEY_PREFIX=libraft-aarch64 # [aarch64] - - SCCACHE_S3_KEY_PREFIX=libraft-linux64 # [linux64] - - SCCACHE_BUCKET=rapids-sccache - - SCCACHE_REGION=us-west-2 - - SCCACHE_IDLE_TIMEOUT=32768 number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + ignore_run_exports_from: + - {{ compiler('cuda') }} requirements: build: + - {{ compiler('c') }} + - {{ compiler('cxx') }} + - {{ compiler('cuda') }} {{ cuda_version }} + - sysroot_{{ target_platform }} {{ sysroot_version }} - cmake {{ cmake_version }} host: - cudatoolkit {{ cuda_version }}.* - libcusolver {{ libcusolver_version }} + - libcusparse {{ libcusparse_version }} - librmm {{ minor_version }} - nccl {{ nccl_version }} - ucx-proc=*=gpu @@ -51,6 +54,7 @@ outputs: run: - cudatoolkit {{ cuda_spec }} - libcusolver {{ libcusolver_version }} + - libcusparse {{ libcusparse_version }} - librmm {{ minor_version }} - nccl {{ nccl_version }} - ucx-proc=*=gpu @@ -65,10 +69,15 @@ outputs: build: number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} - script_env: *script_env + ignore_run_exports_from: + - {{ compiler('cuda') }} requirements: build: - cmake {{ cmake_version }} + - {{ compiler('c') }} + - {{ compiler('cxx') }} + - {{ compiler('cuda') }} {{ cuda_version }} + - sysroot_{{ target_platform }} {{ sysroot_version }} host: - cudatoolkit {{ cuda_version }}.* - librmm {{ minor_version }} @@ -78,11 +87,12 @@ outputs: - {{ pin_subpackage('libraft-headers', exact=True) }} run: - cudatoolkit {{ cuda_spec }} - - libcusolver {{ libcusolver_version }} - librmm {{ minor_version }} - nccl {{ nccl_version }} - ucx-proc=*=gpu - ucx-py {{ ucx_py_version }} + - libcusolver {{ libcusolver_version }} + - libcusparse {{ libcusparse_version }} - {{ pin_subpackage('libraft-headers', exact=True) }} about: home: http://rapids.ai/ @@ -94,10 +104,15 @@ outputs: build: number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} - script_env: *script_env + ignore_run_exports_from: + - {{ compiler('cuda') }} requirements: build: - cmake {{ cmake_version }} + - {{ compiler('c') }} + - {{ compiler('cxx') }} + - {{ compiler('cuda') }} {{ cuda_version }} + - sysroot_{{ target_platform }} {{ sysroot_version }} host: - cudatoolkit {{ cuda_version }}.* - faiss-proc=*=cuda @@ -109,6 +124,7 @@ outputs: - cudatoolkit {{ cuda_spec }} - faiss-proc=*=cuda - libcusolver {{ libcusolver_version }} + - libcusparse {{ libcusparse_version }} - libfaiss {{ libfaiss_version }} - librmm {{ minor_version }} - {{ pin_subpackage('libraft-headers', exact=True) }} @@ -122,10 +138,15 @@ outputs: build: number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} - script_env: *script_env + ignore_run_exports_from: + - {{ compiler('cuda') }} requirements: build: - cmake {{ cmake_version }} + - {{ compiler('c') }} + - {{ compiler('cxx') }} + - {{ compiler('cuda') }} {{ cuda_version }} + - sysroot_{{ target_platform }} {{ sysroot_version }} host: - cudatoolkit {{ cuda_version }}.* - gmock {{ gtest_version }} @@ -137,6 +158,8 @@ outputs: - cudatoolkit {{ cuda_spec }} - gmock {{ gtest_version }} - gtest {{ gtest_version }} + - libcusolver {{ libcusolver_version }} + - libcusparse {{ libcusparse_version }} - {{ pin_subpackage('libraft-distance', exact=True) }} - {{ pin_subpackage('libraft-headers', exact=True) }} - {{ pin_subpackage('libraft-nn', exact=True) }} diff --git a/conda/recipes/pylibraft/build.sh b/conda/recipes/pylibraft/build.sh index 4e64d031ec..558d6fb071 100644 --- a/conda/recipes/pylibraft/build.sh +++ b/conda/recipes/pylibraft/build.sh @@ -2,4 +2,4 @@ #!/usr/bin/env bash # This assumes the script is executed from the root of the repo directory -./build.sh pylibraft --install --no-nvtx +./build.sh pylibraft --install --sccache --no-nvtx diff --git a/conda/recipes/pylibraft/conda_build_config.yaml b/conda/recipes/pylibraft/conda_build_config.yaml new file mode 100644 index 0000000000..aae60bf63a --- /dev/null +++ b/conda/recipes/pylibraft/conda_build_config.yaml @@ -0,0 +1,14 @@ +c_compiler_version: + - 9 + +cxx_compiler_version: + - 9 + +cuda_compiler: + - nvcc + +sysroot_version: + - "2.17" + +cmake_version: + - ">=3.20.1,!=3.23.0" \ No newline at end of file diff --git a/conda/recipes/pylibraft/meta.yaml b/conda/recipes/pylibraft/meta.yaml index 4576e5146f..176d12127b 100644 --- a/conda/recipes/pylibraft/meta.yaml +++ b/conda/recipes/pylibraft/meta.yaml @@ -18,17 +18,20 @@ source: build: number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_py{{ py_version }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} - script_env: - - CC - - CXX - - VERSION_SUFFIX + ignore_run_exports_from: + - {{ compiler('cuda') }} requirements: build: + - {{ compiler('c') }} + - {{ compiler('cxx') }} + - {{ compiler('cuda') }} {{ cuda_version }} + - sysroot_{{ target_platform }} {{ sysroot_version }} + host: - python x.x - setuptools - cython>=0.29,<0.30 - - cmake>=3.20.1,!=3.23.0 + - cmake {{ cmake_version }} - scikit-build>=0.13.1 - rmm {{ minor_version }} - libraft-headers {{ version }} diff --git a/conda/recipes/pyraft/build.sh b/conda/recipes/pyraft/build.sh index 1462f365ff..b290d4463c 100644 --- a/conda/recipes/pyraft/build.sh +++ b/conda/recipes/pyraft/build.sh @@ -3,4 +3,4 @@ # Copyright (c) 2022, NVIDIA CORPORATION. # This assumes the script is executed from the root of the repo directory -./build.sh pyraft --install --no-nvtx +./build.sh pyraft --install --sccache --no-nvtx diff --git a/conda/recipes/pyraft/conda_build_config.yaml b/conda/recipes/pyraft/conda_build_config.yaml index c542be2d20..8546863946 100644 --- a/conda/recipes/pyraft/conda_build_config.yaml +++ b/conda/recipes/pyraft/conda_build_config.yaml @@ -1,2 +1,17 @@ +c_compiler_version: + - 9 + +cxx_compiler_version: + - 9 + +cuda_compiler: + - nvcc + +sysroot_version: + - "2.17" + ucx_version: - "1.12.1" + +cmake_version: + - ">=3.20.1,!=3.23.0" \ No newline at end of file diff --git a/conda/recipes/pyraft/meta.yaml b/conda/recipes/pyraft/meta.yaml index 86159622d3..f3ed6b2f18 100644 --- a/conda/recipes/pyraft/meta.yaml +++ b/conda/recipes/pyraft/meta.yaml @@ -19,17 +19,20 @@ source: build: number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_py{{ py_version }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} - script_env: - - CC - - CXX - - VERSION_SUFFIX + ignore_run_exports_from: + - {{ compiler('cuda') }} requirements: build: + - {{ compiler('c') }} + - {{ compiler('cxx') }} + - {{ compiler('cuda') }} {{ cuda_version }} + - sysroot_{{ target_platform }} {{ sysroot_version }} + host: - python x.x - setuptools - cython>=0.29,<0.30 - - cmake>=3.20.1,!=3.23.0 + - cmake {{ cmake_version }} - scikit-build>=0.13.1 - rmm {{ minor_version }} - libraft-headers {{ version }}