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 #1529

Merged
merged 18 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 13 additions & 4 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jobs:
- conda-python-build
- conda-python-tests
- docs-build
- wheel-build
- wheel-build-cpp
- wheel-build-python
- wheel-tests
- devcontainer
secrets: inherit
Expand Down Expand Up @@ -62,15 +63,23 @@ jobs:
arch: "amd64"
container_image: "rapidsai/ci-conda:latest"
run_script: "ci/build_docs.sh"
wheel-build:
wheel-build-cpp:
needs: checks
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
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.sh
script: ci/build_wheel_cpp.sh
vyasr marked this conversation as resolved.
Show resolved Hide resolved
wheel-build-python:
needs: wheel-build-cpp
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
build_type: pull-request
script: ci/build_wheel_python.sh
wheel-tests:
needs: wheel-build
needs: wheel-build-python
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ set_property(CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WA
# build type for cmake-gui
message(STATUS "RMM: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'")

# cudart can be statically linked or dynamically linked the python ecosystem wants dynamic linking
# cudart can be linked statically or dynamically
option(CUDA_STATIC_RUNTIME "Statically link the CUDA runtime" OFF)

# ##################################################################################################
Expand Down
8 changes: 1 addition & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@ if hasArg --ptds; then
PER_THREAD_DEFAULT_STREAM=ON
fi

# Append `-DFIND_RMM_CPP=ON` to CMAKE_ARGS unless a user specified the option.
SKBUILD_EXTRA_CMAKE_ARGS="${EXTRA_CMAKE_ARGS}"
if [[ "${EXTRA_CMAKE_ARGS}" != *"DFIND_RMM_CPP"* ]]; then
SKBUILD_EXTRA_CMAKE_ARGS="${SKBUILD_EXTRA_CMAKE_ARGS} -DFIND_RMM_CPP=ON"
fi

# If clean given, run it prior to any other steps
if hasArg clean; then
# If the dirs to clean are mounted dirs in a container, the
Expand Down Expand Up @@ -176,5 +170,5 @@ fi
# Build and install the rmm Python package
if (( NUMARGS == 0 )) || hasArg rmm; then
echo "building and installing rmm..."
SKBUILD_CMAKE_ARGS="${SKBUILD_EXTRA_CMAKE_ARGS}" python -m pip install --no-build-isolation --no-deps ${REPODIR}/python/rmm
SKBUILD_CMAKE_ARGS="${EXTRA_CMAKE_ARGS}" python -m pip install --no-build-isolation --no-deps ${REPODIR}/python/rmm
fi
32 changes: 32 additions & 0 deletions ci/build_wheel_cpp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

package_name="librmm"
package_dir="python/librmm"

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

version=$(rapids-generate-version)
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}"
vyasr marked this conversation as resolved.
Show resolved Hide resolved

pyproject_file="${package_dir}/pyproject.toml"

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

cd "${package_dir}"

python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check
python -m pip install wheel
python -m wheel tags --platform any dist/* --remove
RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 cpp dist
12 changes: 10 additions & 2 deletions ci/build_wheel.sh → ci/build_wheel_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,23 @@ sed -i "s/name = \"${package_name}\"/name = \"${package_name}${PACKAGE_CUDA_SUFF
echo "${version}" > VERSION
sed -i "/^__git_commit__/ s/= .*/= \"${commit}\"/g" "${package_dir}/${package_name}/_version.py"

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

cd "${package_dir}"

python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check
CPP_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp /tmp/librmm_dist)

python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check --find-links "${CPP_WHEELHOUSE}"

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

RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 final_dist
RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 python final_dist
5 changes: 3 additions & 2 deletions ci/test_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
set -eou pipefail

RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"
RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 ./dist
WHEELHOUSE="${PWD}/dist/"
RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 python "${WHEELHOUSE}"

# echo to expand wildcard before adding `[extra]` requires for pip
python -m pip install $(echo ./dist/rmm*.whl)[test]
python -m pip install "rmm-${RAPIDS_PY_CUDA_SUFFIX}[test]>=0.0.0a0" --find-links "${WHEELHOUSE}"

python -m pytest ./python/rmm/rmm/tests
20 changes: 20 additions & 0 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ files:
- cuda_version
- docs
- py_version
py_cpp_build:
output: pyproject
pyproject_dir: python/librmm
extras:
table: build-system
includes:
- build
py_build:
output: pyproject
pyproject_dir: python/rmm
Expand Down Expand Up @@ -125,6 +132,19 @@ dependencies:
- matrix: # All CUDA 11 versions
packages:
- &cuda_python11 cuda-python>=11.7.1,<12.0a0
- output_types: [requirements, pyproject]
matrices:
- matrix:
cuda: "12.*"
packages:
- librmm-cu12==24.6.*
- matrix:
cuda: "11.*"
packages:
- librmm-cu11==24.6.*
- matrix:
packages:
- librmm==24.6.*
checks:
common:
- output_types: [conda, requirements]
Expand Down
38 changes: 38 additions & 0 deletions python/librmm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# =============================================================================
# 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.26.4 FATAL_ERROR)

include(../../rapids_config.cmake)

project(
librmm-python
VERSION "${RAPIDS_VERSION}"
LANGUAGES CXX)

# Check if rmm is already available. If so, it is the user's responsibility to ensure that the CMake
# package is also available at build time of the Python rmm package.
find_package(rmm "${RAPIDS_VERSION}")

if(rmm_FOUND)
return()
endif()

unset(rmm_FOUND)

set(BUILD_TESTS OFF)
set(BUILD_BENCHMARKS OFF)
set(CUDA_STATIC_RUNTIME ON)

add_subdirectory(../.. rmm-cpp)
vyasr marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions python/librmm/LICENSE
1 change: 1 addition & 0 deletions python/librmm/README.md
1 change: 1 addition & 0 deletions python/librmm/librmm/VERSION
15 changes: 15 additions & 0 deletions python/librmm/librmm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2024, 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.

from librmm._version import __git_commit__, __version__
20 changes: 20 additions & 0 deletions python/librmm/librmm/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2024, 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.

import importlib.resources

__version__ = (
importlib.resources.files("librmm").joinpath("VERSION").read_text().strip()
)
__git_commit__ = ""
60 changes: 60 additions & 0 deletions python/librmm/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright (c) 2024, 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.

[build-system]
build-backend = "scikit_build_core.build"
requires = [
"cmake>=3.26.4",
"ninja",
"scikit-build-core[pyproject]>=0.7.0",
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.

[project]
name = "librmm"
dynamic = ["version"]
description = "rmm - RAPIDS Memory Manager"
readme = { file = "README.md", content-type = "text/markdown" }
authors = [
{ name = "NVIDIA Corporation" },
]
license = { text = "Apache 2.0" }
classifiers = [
"Intended Audience :: Developers",
"Topic :: Database",
"Topic :: Scientific/Engineering",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: C++",
"Environment :: GPU :: NVIDIA CUDA",
]

[project.urls]
Homepage = "https://github.com/rapidsai/rmm"

[project.entry-points."cmake.prefix"]
librmm = "librmm"

[tool.scikit-build]
build-dir = "build/{wheel_tag}"
cmake.build-type = "Release"
cmake.minimum-version = "3.26.4"
ninja.make-fallback = true
sdist.reproducible = true
wheel.packages = ["librmm"]
wheel.install-dir = "librmm"
wheel.py-api = "py3"

[tool.scikit-build.metadata.version]
provider = "scikit_build_core.metadata.regex"
input = "librmm/VERSION"
regex = "(?P<value>.*)"
18 changes: 1 addition & 17 deletions python/rmm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,7 @@ project(
VERSION "${RAPIDS_VERSION}"
LANGUAGES CXX)

option(FIND_RMM_CPP "Search for existing RMM C++ installations before defaulting to local files"
OFF)

# If the user requested it we attempt to find RMM.
if(FIND_RMM_CPP)
find_package(rmm "${RAPIDS_VERSION}")
else()
set(rmm_FOUND OFF)
endif()

if(NOT rmm_FOUND)
set(BUILD_TESTS OFF)
set(BUILD_BENCHMARKS OFF)
set(CUDA_STATIC_RUNTIME ON)

add_subdirectory(../../ rmm-cpp EXCLUDE_FROM_ALL)
endif()
find_package(rmm "${RAPIDS_VERSION}" REQUIRED)

include(rapids-cython-core)
rapids_cython_init()
Expand Down
1 change: 1 addition & 0 deletions python/rmm/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ requires = [
"cmake>=3.26.4",
"cuda-python>=11.7.1,<12.0a0",
"cython>=3.0.0",
"librmm==24.6.*",
"ninja",
"scikit-build-core[pyproject]>=0.7.0",
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
Expand Down
Loading