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

Build C++ wheel #2264

Merged
merged 63 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
6b255bd
Add libraft package
vyasr Mar 29, 2024
27aefec
Update dependencies.yaml
vyasr Mar 29, 2024
86c5c83
Get libraft building
vyasr Mar 29, 2024
6fd0c64
Add libraft as dependency
vyasr Mar 29, 2024
d360ae7
Make librmm a runtime dependency of libraft
vyasr Mar 29, 2024
2aac72a
Change pylibraft to use libraft wheel
vyasr Mar 30, 2024
cea9746
Don't error
vyasr Mar 30, 2024
834c252
Fix name
vyasr Mar 30, 2024
2376937
Remove RPATH hacking in favor of dynamic loading.
vyasr Mar 31, 2024
c252e35
Remove now extraneous ASSOCIATED_TARGETS
vyasr Mar 31, 2024
bd57f69
Make loading the library opt-in rather than automatic on import
vyasr Mar 31, 2024
3cf64c6
Support disabling the static library build
vyasr Apr 1, 2024
97b2692
Add build in CI
vyasr Apr 1, 2024
e075ab8
WAR dependencies
vyasr Apr 1, 2024
ec178d5
Combine Python wheel building steps
vyasr Apr 1, 2024
070c171
Temporarily disable raft-dask builds since the package hasn't been up…
vyasr Apr 1, 2024
2764c9f
Pull rmm from the PR
vyasr Apr 1, 2024
833507c
Fix GHA
vyasr Apr 1, 2024
0fb2aae
Disambiguate dists
vyasr Apr 1, 2024
f256bd1
Download librmm for the libraft build
vyasr Apr 1, 2024
078a284
Fix rmm artifact name
vyasr Apr 1, 2024
d4fd16f
Bug
vyasr Apr 1, 2024
0214978
Fix variable
vyasr Apr 1, 2024
6908580
Fix find links
vyasr Apr 2, 2024
fd02fc3
Make wheel py3
vyasr Apr 2, 2024
b2f58a3
Fix sed
vyasr Apr 2, 2024
1f73ba7
Exclude libraft.so from auditwheel
vyasr Apr 2, 2024
e871cbc
Make libraft a runtime dependency of the wheel
vyasr Apr 2, 2024
4b88255
Also download libraft wheel
vyasr Apr 2, 2024
d15c098
Also add the rmm wheelhouse
vyasr Apr 2, 2024
2cccc76
Specify py version for libraft download
vyasr Apr 2, 2024
fcbf48b
Specify version correctly...
vyasr Apr 2, 2024
ace582d
Update to use latest tools
vyasr Apr 2, 2024
3fb9ce7
typo
vyasr Apr 2, 2024
3e77844
Get rid of extension
vyasr Apr 2, 2024
3ab6d6a
Specify the wheel name to get
vyasr Apr 2, 2024
63a657d
Add missing underscore
vyasr Apr 2, 2024
0aa6711
Specify var in command
vyasr Apr 3, 2024
006c3e5
Move all exports out of conditional
vyasr Apr 3, 2024
a53fe64
Updates for raft-dask
vyasr Apr 11, 2024
643f700
More updates
vyasr Apr 11, 2024
c36b69c
Fix dependency links
vyasr Apr 12, 2024
a3fa4fd
Remove unnecessary clones
vyasr Apr 17, 2024
110c26f
Simplify wheel building script
vyasr Apr 17, 2024
a358b52
Remove more clones
vyasr Apr 17, 2024
888ed93
More pip conda alignment
vyasr Apr 17, 2024
e2e0902
Standardize test scripts
vyasr Apr 17, 2024
9bb484b
Centralize testing logic
vyasr Apr 17, 2024
d94ce97
Fix rmm name
vyasr Apr 17, 2024
0435e6b
Add suffix to install command
vyasr Apr 17, 2024
efafdb6
Only audit once and fix varname
vyasr Apr 17, 2024
0f50932
Make VERSION a symlink
vyasr Apr 18, 2024
de84193
Stop pulling rmm from PR and add package name back to artifacts
vyasr May 6, 2024
f3336ba
Update build.yaml
vyasr May 6, 2024
bcc7107
Minor CMake cleanup
vyasr May 6, 2024
674e9ef
Update dependencies.yaml
vyasr May 6, 2024
d012e76
Update CMake and loading for devcontainer use case
vyasr May 6, 2024
c7d8010
Merge remote-tracking branch 'origin/branch-24.06' into feat/cpp_wheel
vyasr May 6, 2024
23ad581
Update build.sh
vyasr May 6, 2024
212fa0d
Fix test script
vyasr May 6, 2024
c964826
Merge remote-tracking branch 'upstream/branch-24.06' into feat/cpp_wheel
vyasr May 7, 2024
927c6d6
Merge remote-tracking branch 'upstream/branch-24.06' into feat/cpp_wheel
vyasr May 7, 2024
6b3ab9f
Add matrixed dependencies
vyasr May 7, 2024
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
30 changes: 17 additions & 13 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,42 +67,46 @@ jobs:
node_type: "gpu-v100-latest-1"
run_script: "ci/build_docs.sh"
sha: ${{ inputs.sha }}
wheel-build-pylibraft:
wheel-build-cpp:
needs: checks
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.06
with:
matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber)))
build_type: ${{ inputs.build_type || 'branch' }}
branch: ${{ inputs.branch }}
sha: ${{ inputs.sha }}
date: ${{ inputs.date }}
script: ci/build_wheel_pylibraft.sh
wheel-publish-pylibraft:
needs: wheel-build-pylibraft
script: ci/build_wheel_cpp.sh
wheel-build-python:
needs: wheel-build-cpp
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.06
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.06
with:
build_type: ${{ inputs.build_type || 'branch' }}
branch: ${{ inputs.branch }}
sha: ${{ inputs.sha }}
date: ${{ inputs.date }}
package-name: pylibraft
wheel-build-raft-dask:
needs: wheel-publish-pylibraft
script: ci/build_wheel_python.sh
wheel-publish-cpp:
needs: wheel-build-cpp
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.06
uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.06
with:
build_type: ${{ inputs.build_type || 'branch' }}
branch: ${{ inputs.branch }}
sha: ${{ inputs.sha }}
date: ${{ inputs.date }}
script: ci/build_wheel_raft_dask.sh
wheel-publish-raft-dask:
needs: wheel-build-raft-dask
package-name: raft
package-type: cpp
wheel-publish-python:
needs: wheel-build-python
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.06
with:
build_type: ${{ inputs.build_type || 'branch' }}
branch: ${{ inputs.branch }}
sha: ${{ inputs.sha }}
date: ${{ inputs.date }}
package-name: raft_dask
package-name: raft
package-type: python
27 changes: 14 additions & 13 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
- conda-python-build
- conda-python-tests
- docs-build
- wheel-build-pylibraft
- wheel-build-cpp
- wheel-build-python
- wheel-tests-pylibraft
- wheel-build-raft-dask
- wheel-tests-raft-dask
- devcontainer
secrets: inherit
Expand Down Expand Up @@ -74,29 +74,30 @@ jobs:
arch: "amd64"
container_image: "rapidsai/ci-conda:latest"
run_script: "ci/build_docs.sh"
wheel-build-pylibraft:
wheel-build-cpp:
needs: checks
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.06
with:
matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber)))
build_type: pull-request
script: ci/build_wheel_pylibraft.sh
wheel-tests-pylibraft:
needs: wheel-build-pylibraft
script: ci/build_wheel_cpp.sh
wheel-build-python:
needs: wheel-build-cpp
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.06
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.06
with:
build_type: pull-request
script: ci/test_wheel_pylibraft.sh
wheel-build-raft-dask:
needs: wheel-tests-pylibraft
script: ci/build_wheel_python.sh
wheel-tests-pylibraft:
needs: wheel-build-python
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.06
uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.06
with:
build_type: pull-request
script: "ci/build_wheel_raft_dask.sh"
script: ci/test_wheel_pylibraft.sh
wheel-tests-raft-dask:
needs: wheel-build-raft-dask
needs: wheel-build-python
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.06
with:
Expand Down
12 changes: 2 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,6 @@ if [[ ${CMAKE_TARGET} == "" ]]; then
CMAKE_TARGET="all"
fi

# Append `-DFIND_RAFT_CPP=ON` to EXTRA_CMAKE_ARGS unless a user specified the option.
SKBUILD_EXTRA_CMAKE_ARGS="${EXTRA_CMAKE_ARGS}"
if [[ "${EXTRA_CMAKE_ARGS}" != *"DFIND_RAFT_CPP"* ]]; then
SKBUILD_EXTRA_CMAKE_ARGS="${SKBUILD_EXTRA_CMAKE_ARGS} -DFIND_RAFT_CPP=ON"
fi
# Replace spaces with semicolons in SKBUILD_EXTRA_CMAKE_ARGS
SKBUILD_EXTRA_CMAKE_ARGS=$(echo ${SKBUILD_EXTRA_CMAKE_ARGS} | sed 's/ /;/g')

# If clean given, run it prior to any other steps
if (( ${CLEAN} == 1 )); then
# If the dirs to clean are mounted dirs in a container, the
Expand Down Expand Up @@ -495,13 +487,13 @@ fi

# Build and (optionally) install the pylibraft Python package
if (( ${NUMARGS} == 0 )) || hasArg pylibraft; then
SKBUILD_CMAKE_ARGS="${SKBUILD_EXTRA_CMAKE_ARGS}" \
CMAKE_ARGS="${EXTRA_CMAKE_ARGS}" \
python -m pip install --no-build-isolation --no-deps ${REPODIR}/python/pylibraft
fi

# Build and (optionally) install the raft-dask Python package
if (( ${NUMARGS} == 0 )) || hasArg raft-dask; then
SKBUILD_CMAKE_ARGS="${SKBUILD_EXTRA_CMAKE_ARGS}" \
CMAKE_ARGS="${EXTRA_CMAKE_ARGS}" \
python -m pip install --no-build-isolation --no-deps ${REPODIR}/python/raft-dask
fi

Expand Down
67 changes: 0 additions & 67 deletions ci/build_wheel.sh

This file was deleted.

46 changes: 46 additions & 0 deletions ci/build_wheel_cpp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

package_name="libraft"
package_dir="python/libraft"

source rapids-configure-sccache
source rapids-date-string

version=$(rapids-generate-version)
git_commit=$(git rev-parse HEAD)

RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"

# everywhere except in the final wheel name.
PACKAGE_CUDA_SUFFIX="-${RAPIDS_PY_CUDA_SUFFIX}"

# Patch project metadata files to include the CUDA version suffix and version override.
pyproject_file="${package_dir}/pyproject.toml"
version_file="${package_dir}/${package_name}/_version.py"

sed -i "s/name = \"${package_name}\"/name = \"${package_name}${PACKAGE_CUDA_SUFFIX}\"/g" ${pyproject_file}
echo "${version}" > VERSION
sed -i "/^__git_commit__ / s/= .*/= \"${git_commit}\"/g" ${version_file}

# For nightlies we want to ensure that we're pulling in alphas as well. The
# easiest way to do so is to augment the spec with a constraint containing a
# min alpha version that doesn't affect the version bounds but does allow usage
# of alpha versions for that dependency without --pre
alpha_spec=''
if ! rapids-is-release-build; then
alpha_spec=',>=0.0.0a0'
fi

sed -r -i "s/librmm(.*)\"/librmm${PACKAGE_CUDA_SUFFIX}\1${alpha_spec}\"/g" ${pyproject_file}

cd "${package_dir}"

python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check

mkdir -p final_dist
python -m auditwheel repair -w final_dist dist/*

RAPIDS_PY_WHEEL_NAME="raft_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 cpp final_dist
9 changes: 0 additions & 9 deletions ci/build_wheel_pylibraft.sh

This file was deleted.

84 changes: 84 additions & 0 deletions ci/build_wheel_python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/bin/bash
# Copyright (c) 2023-2024, NVIDIA CORPORATION.

set -euo pipefail

# Clear out system ucx files to ensure that we're getting ucx from the wheel
# when building raft-dask.
rm -rf /usr/lib64/ucx
rm -rf /usr/lib64/libuc*

source rapids-configure-sccache
source rapids-date-string

version=$(rapids-generate-version)
git_commit=$(git rev-parse HEAD)

RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"

# This is the version of the suffix with a preceding hyphen. It's used
# everywhere except in the final wheel name.
PACKAGE_CUDA_SUFFIX="-${RAPIDS_PY_CUDA_SUFFIX}"

echo "${version}" > VERSION

# For nightlies we want to ensure that we're pulling in alphas as well. The
# easiest way to do so is to augment the spec with a constraint containing a
# min alpha version that doesn't affect the version bounds but does allow usage
# of alpha versions for that dependency without --pre
alpha_spec=''
if ! rapids-is-release-build; then
alpha_spec=',>=0.0.0a0'
fi

CPP_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="raft_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp /tmp/libraft_dist)
PYTHON_WHEELHOUSE="${PWD}/dist/"
PYTHON_AUDITED_WHEELHOUSE="${PWD}/final_dist/"
WHEELHOUSES=("${PYTHON_WHEELHOUSE}" "${CPP_WHEELHOUSE}")
mkdir -p "${PYTHON_AUDITED_WHEELHOUSE}"

FIND_LINKS=""
# Iterate over the array
for wheelhouse in "${WHEELHOUSES[@]}"; do
FIND_LINKS+="--find-links ${wheelhouse} "
done


build_wheel () {
local package_name="${1}"
local underscore_package_name=$(echo "${package_name}" | tr "-" "_")

local package_dir="python/${package_name}"
local pyproject_file="${package_dir}/pyproject.toml"
local version_file="${package_dir}/${underscore_package_name}/_version.py"

sed -i "s/name = \"${package_name}\"/name = \"${package_name}${PACKAGE_CUDA_SUFFIX}\"/g" ${pyproject_file}
sed -i "/^__git_commit__ / s/= .*/= \"${git_commit}\"/g" ${version_file}

sed -r -i "s/libucx(.*)\"/libucx${PACKAGE_CUDA_SUFFIX}\1${alpha_spec}\"/g" ${pyproject_file}

for dep in rmm libraft pylibraft ucx-py distributed-ucxx; do
sed -r -i "s/${dep}==(.*)\"/${dep}${PACKAGE_CUDA_SUFFIX}==\1${alpha_spec}\"/g" ${pyproject_file}
done

# dask-cuda & rapids-dask-dependency don't get a suffix, but they do get an alpha spec.
for dep in dask-cuda rapids-dask-dependency; do
sed -r -i "s/${dep}==(.*)\"/${dep}==\1${alpha_spec}\"/g" ${pyproject_file}
done

if [[ $PACKAGE_CUDA_SUFFIX == "-cu12" ]]; then
sed -i "s/cuda-python[<=>\.,0-9a]*/cuda-python>=12.0,<13.0a0/g" ${pyproject_file}
sed -i "s/cupy-cuda11x/cupy-cuda12x/g" ${pyproject_file}
fi

pushd "${package_dir}"

python -m pip wheel . -w "${PYTHON_WHEELHOUSE}" -vvv --no-deps --disable-pip-version-check ${FIND_LINKS}
popd
}

build_wheel pylibraft
build_wheel raft-dask

python -m auditwheel repair -w "${PYTHON_AUDITED_WHEELHOUSE}" --exclude libraft.so --exclude "libucp.so.0" "${PYTHON_WHEELHOUSE}"/*
RAPIDS_PY_WHEEL_NAME="raft_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 python "${PYTHON_AUDITED_WHEELHOUSE}"
9 changes: 0 additions & 9 deletions ci/build_wheel_raft_dask.sh

This file was deleted.

11 changes: 6 additions & 5 deletions ci/test_wheel_pylibraft.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

set -euo pipefail

mkdir -p ./dist
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"
RAPIDS_PY_WHEEL_NAME="pylibraft_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 ./dist

# echo to expand wildcard before adding `[extra]` requires for pip
python -m pip install $(echo ./dist/pylibraft*.whl)[test]
WHEELHOUSE="${PWD}/dist/"
RAPIDS_PY_WHEEL_NAME="raft_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp "${WHEELHOUSE}"
RAPIDS_PY_WHEEL_NAME="raft_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 python "${WHEELHOUSE}"

python -m pytest ./python/pylibraft/pylibraft/test
python -m pip install "pylibraft-${RAPIDS_PY_CUDA_SUFFIX}[test]>=0.0.0a0" --find-links "${WHEELHOUSE}"

python -m pytest python/pylibraft/pylibraft/test
Loading
Loading