From 6c7d930125cd84ab2655421cbf8847046142579d Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 23 Oct 2024 13:37:43 -0500 Subject: [PATCH] print sccache stats --- .pre-commit-config.yaml | 2 +- ci/build_cpp.sh | 2 ++ ci/build_python.sh | 5 +++++ ci/build_wheel.sh | 28 +++------------------------- ci/build_wheel_cugraph.sh | 33 ++++++++++++++++++++++++--------- ci/build_wheel_pylibcugraph.sh | 23 ++++++++++++++++++++++- 6 files changed, 57 insertions(+), 36 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3687562b48e..b5fbcf9ad42 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,7 +55,7 @@ repos: setup[.]cfg$ - id: verify-alpha-spec - repo: https://github.com/rapidsai/dependency-file-generator - rev: v1.13.11 + rev: v1.16.0 hooks: - id: rapids-dependency-file-generator args: ["--clean"] diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 859977d76d5..93e5c680d07 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -17,4 +17,6 @@ rapids-logger "Begin cpp build" RAPIDS_PACKAGE_VERSION=$(rapids-generate-version) rapids-conda-retry mambabuild conda/recipes/libcugraph +sccache --show-adv-stats + rapids-upload-conda-to-s3 cpp diff --git a/ci/build_python.sh b/ci/build_python.sh index c94cc2a0fce..b49d5f534aa 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -27,12 +27,17 @@ rapids-conda-retry mambabuild \ --channel "${CPP_CHANNEL}" \ conda/recipes/pylibcugraph +sccache --show-adv-stats +sccache --zero-stats + rapids-conda-retry mambabuild \ --no-test \ --channel "${CPP_CHANNEL}" \ --channel "${RAPIDS_CONDA_BLD_OUTPUT_DIR}" \ conda/recipes/cugraph +sccache --show-adv-stats + # NOTE: nothing in nx-cugraph is CUDA-specific, but it is built on each CUDA # platform to ensure it is included in each set of artifacts, since test # scripts only install from one set of artifacts based on the CUDA version used diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh index 31aa323e454..958a56bbe77 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel.sh @@ -5,43 +5,21 @@ set -euo pipefail package_name=$1 package_dir=$2 -underscore_package_name=$(echo "${package_name}" | tr "-" "_") source rapids-configure-sccache source rapids-date-string RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" -rapids-logger "Generating build requirements" -matrix_selectors="cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION};cuda_suffixed=true" - -rapids-dependency-file-generator \ - --output requirements \ - --file-key "py_build_${underscore_package_name}" \ - --matrix "${matrix_selectors}" \ -| tee /tmp/requirements-build.txt - -rapids-dependency-file-generator \ - --output requirements \ - --file-key "py_rapids_build_${underscore_package_name}" \ - --matrix "${matrix_selectors}" \ -| tee -a /tmp/requirements-build.txt - -rapids-logger "Installing build requirements" -python -m pip install \ - -v \ - --prefer-binary \ - -r /tmp/requirements-build.txt - rapids-generate-version > ./VERSION cd "${package_dir}" -rapids-logger "Building '${package_name}' wheel" +sccache --zero-stats + python -m pip wheel \ -w dist \ -v \ - --no-build-isolation \ --no-deps \ --disable-pip-version-check \ --extra-index-url https://pypi.nvidia.com \ @@ -54,7 +32,7 @@ if [[ ${package_name} == "nx-cugraph" ]] || \ [[ ${package_name} == "cugraph-dgl" ]] || \ [[ ${package_name} == "cugraph-pyg" ]] || \ [[ ${package_name} == "cugraph-equivariant" ]]; then - RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" RAPIDS_PY_WHEEL_PURE="1" rapids-upload-wheels-to-s3 dist + RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" RAPIDS_PY_WHEEL_PURE="1" rapids-upload-wheels-to-s3 python dist else case "${RAPIDS_CUDA_VERSION}" in 12.*) diff --git a/ci/build_wheel_cugraph.sh b/ci/build_wheel_cugraph.sh index 20d9bf47e3e..694d32c9e83 100755 --- a/ci/build_wheel_cugraph.sh +++ b/ci/build_wheel_cugraph.sh @@ -3,22 +3,37 @@ set -euo pipefail -RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" +package_name="pylibcugraph" -# Download the pylibcugraph wheel built in the previous step and make it -# available for pip to find. -# -# ensure 'cugraph' wheel builds always use the 'pylibcugraph' just built in the same CI run +rapids-logger "Generating build requirements" + +rapids-dependency-file-generator \ + --output requirements \ + --file-key "py_build_${package_name}" \ + --file-key "py_rapids_build_${package_name}" \ + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION};cuda_suffixed=true" \ +| tee /tmp/requirements-build.txt + +# Download the pylibcugraph wheel built in the previous step and install it in the build environment. # -# using env variable PIP_CONSTRAINT is necessary to ensure the constraints -# are used when creating the isolated build environment +# Ensures 'cugraph' wheel builds always use the 'pylibcugraph' just built in the same CI run. +RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" CPP_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="pylibcugraph_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 /tmp/pylibcugraph_dist) +echo "$(echo ${CPP_WHEELHOUSE}/pylibcugraph_${RAPIDS_PY_CUDA_SUFFIX}*.whl)" >> /tmp/requirements-build.txt + +rapids-logger "Installing build requirements" +python -m pip install \ + -v \ + --prefer-binary \ + -r /tmp/requirements-build.txt -echo "pylibcugraph-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo ${CPP_WHEELHOUSE}/pylibcugraph_*.whl)" > ./constraints.txt -export PIP_CONSTRAINT="${PWD}/constraints.txt" +# build with '--no-build-isolation', for better sccache hit rate +# 0 really means "add --no-build-isolation" (ref: https://github.com/pypa/pip/issues/5735) +export PIP_NO_BUILD_ISOLATION=0 PARALLEL_LEVEL=$(python -c \ "from math import ceil; from multiprocessing import cpu_count; print(ceil(cpu_count()/4))") + case "${RAPIDS_CUDA_VERSION}" in 12.*) EXTRA_CMAKE_ARGS=";-DUSE_CUDA_MATH_WHEELS=ON" diff --git a/ci/build_wheel_pylibcugraph.sh b/ci/build_wheel_pylibcugraph.sh index fa967b0be29..f7a9b72e21e 100755 --- a/ci/build_wheel_pylibcugraph.sh +++ b/ci/build_wheel_pylibcugraph.sh @@ -3,6 +3,27 @@ set -euo pipefail +package_name="pylibcugraph" + +rapids-logger "Generating build requirements" + +rapids-dependency-file-generator \ + --output requirements \ + --file-key "py_build_${package_name}" \ + --file-key "py_rapids_build_${package_name}" \ + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION};cuda_suffixed=true" \ +| tee /tmp/requirements-build.txt + +rapids-logger "Installing build requirements" +python -m pip install \ + -v \ + --prefer-binary \ + -r /tmp/requirements-build.txt + +# build with '--no-build-isolation', for better sccache hit rate +# 0 really means "add --no-build-isolation" (ref: https://github.com/pypa/pip/issues/5735) +export PIP_NO_BUILD_ISOLATION=0 + PARALLEL_LEVEL=$(python -c \ "from math import ceil; from multiprocessing import cpu_count; print(ceil(cpu_count()/4))") @@ -18,4 +39,4 @@ esac export SKBUILD_CMAKE_ARGS="-DDETECT_CONDA_ENV=OFF;-DFIND_CUGRAPH_CPP=OFF;-DCPM_cugraph-ops_SOURCE=${GITHUB_WORKSPACE}/cugraph-ops/${EXTRA_CMAKE_ARGS}" export SKBUILD_BUILD_TOOL_ARGS="-j${PARALLEL_LEVEL};-l${PARALLEL_LEVEL}" -./ci/build_wheel.sh pylibcugraph python/pylibcugraph +./ci/build_wheel.sh "${package_name}" python/pylibcugraph