diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 2abbfd078..96e4503b7 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -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 @@ -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/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.sh + script: ci/build_wheel_cpp.sh + wheel-build-python: + needs: wheel-build-cpp + secrets: inherit + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.06 + 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/wheels-test.yaml@branch-24.06 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index fd0ab3422..62a192b7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) # ################################################################################################## diff --git a/build.sh b/build.sh index fce8e0586..a52a9f594 100755 --- a/build.sh +++ b/build.sh @@ -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 @@ -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 diff --git a/ci/build_wheel_cpp.sh b/ci/build_wheel_cpp.sh new file mode 100755 index 000000000..e61f6641c --- /dev/null +++ b/ci/build_wheel_cpp.sh @@ -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}" + +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 diff --git a/ci/build_wheel.sh b/ci/build_wheel_python.sh similarity index 74% rename from ci/build_wheel.sh rename to ci/build_wheel_python.sh index b76e882b3..54234ed20 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel_python.sh @@ -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 diff --git a/ci/test_wheel.sh b/ci/test_wheel.sh index 3faf15ba2..6f14a0d45 100755 --- a/ci/test_wheel.sh +++ b/ci/test_wheel.sh @@ -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 diff --git a/dependencies.yaml b/dependencies.yaml index 232f9bddd..eb2c4e4f2 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -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 @@ -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] diff --git a/python/librmm/CMakeLists.txt b/python/librmm/CMakeLists.txt new file mode 100644 index 000000000..0217eb6fa --- /dev/null +++ b/python/librmm/CMakeLists.txt @@ -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) diff --git a/python/librmm/LICENSE b/python/librmm/LICENSE new file mode 120000 index 000000000..30cff7403 --- /dev/null +++ b/python/librmm/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/python/librmm/README.md b/python/librmm/README.md new file mode 120000 index 000000000..fe8400541 --- /dev/null +++ b/python/librmm/README.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/python/librmm/librmm/VERSION b/python/librmm/librmm/VERSION new file mode 120000 index 000000000..d62dc733e --- /dev/null +++ b/python/librmm/librmm/VERSION @@ -0,0 +1 @@ +../../../VERSION \ No newline at end of file diff --git a/python/librmm/librmm/__init__.py b/python/librmm/librmm/__init__.py new file mode 100644 index 000000000..b914ecdc3 --- /dev/null +++ b/python/librmm/librmm/__init__.py @@ -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__ diff --git a/python/librmm/librmm/_version.py b/python/librmm/librmm/_version.py new file mode 100644 index 000000000..ea50101b2 --- /dev/null +++ b/python/librmm/librmm/_version.py @@ -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__ = "" diff --git a/python/librmm/pyproject.toml b/python/librmm/pyproject.toml new file mode 100644 index 000000000..4b997be9a --- /dev/null +++ b/python/librmm/pyproject.toml @@ -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.*)" diff --git a/python/rmm/CMakeLists.txt b/python/rmm/CMakeLists.txt index 22b5ea282..0a472d42f 100644 --- a/python/rmm/CMakeLists.txt +++ b/python/rmm/CMakeLists.txt @@ -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() diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 9ad6d6bbf..c799f101a 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -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`.