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

Add libucxx wheel #260

Merged
merged 18 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
20 changes: 20 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,27 @@ jobs:
branch: ${{ inputs.branch }}
date: ${{ inputs.date }}
sha: ${{ inputs.sha }}
wheel-build-libucxx:
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10
with:
build_type: ${{ inputs.build_type || 'branch' }}
branch: ${{ inputs.branch }}
sha: ${{ inputs.sha }}
date: ${{ inputs.date }}
script: ci/build_wheel_ucxx.sh
wheel-publish-libucxx:
needs: wheel-build-libucxx
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.10
with:
build_type: ${{ inputs.build_type || 'branch' }}
branch: ${{ inputs.branch }}
sha: ${{ inputs.sha }}
date: ${{ inputs.date }}
package-name: libucxx
wheel-build-ucxx:
needs: wheel-build-libucxx
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10
with:
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- conda-cpp-tests
- conda-python-tests
- conda-python-distributed-tests
- wheel-build-libucxx
- wheel-build-ucxx
- wheel-tests-ucxx
- wheel-build-distributed-ucxx
Expand Down Expand Up @@ -67,10 +68,17 @@ jobs:
build_type: pull-request
script: "ci/test_python_distributed.sh"
container-options: "--cap-add CAP_SYS_PTRACE --shm-size=8g --ulimit=nofile=1000000:1000000"
wheel-build-ucxx:
wheel-build-libucxx:
needs: checks
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10
with:
build_type: pull-request
script: ci/build_wheel_libucxx.sh
wheel-build-ucxx:
needs: wheel-build-libucxx
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10
with:
build_type: pull-request
script: ci/build_wheel_ucxx.sh
Expand Down
15 changes: 13 additions & 2 deletions ci/build_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,23 @@ if [[ ${package_name} == "distributed-ucxx" ]]; then
python -m pip wheel "${package_dir}/" -w "${package_dir}/dist" -vvv --no-deps --disable-pip-version-check

RAPIDS_PY_WHEEL_NAME="distributed_ucxx_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 ${package_dir}/dist
elif [[ ${package_name} == "ucxx" ]]; then
SKBUILD_CMAKE_ARGS="-DUCXX_ENABLE_RMM=ON;-DCMAKE_INSTALL_LIBDIR=ucxx/lib64;-DCMAKE_INSTALL_INCLUDEDIR=ucxx/include" \
elif [[ ${package_name} == "libucxx" ]]; then
SKBUILD_CMAKE_ARGS="-DUCXX_ENABLE_RMM=ON" \
python -m pip wheel "${package_dir}"/ -w "${package_dir}"/dist -vvv --no-deps --disable-pip-version-check

python -m auditwheel repair -w ${package_dir}/final_dist --exclude "libucp.so.0" ${package_dir}/dist/*

RAPIDS_PY_WHEEL_NAME="libucxx_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 ${package_dir}/final_dist
KyleFromNVIDIA marked this conversation as resolved.
Show resolved Hide resolved
elif [[ ${package_name} == "ucxx" ]]; then
CPP_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="libucxx_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp /tmp/libucxx_dist)
echo "libucxx-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo ${CPP_WHEELHOUSE}/libucxx_*.whl)" > "${package_dir}/constraints.txt"
KyleFromNVIDIA marked this conversation as resolved.
Show resolved Hide resolved

PIP_CONSTRAINT="${package_dir}/constraints.txt" \
SKBUILD_CMAKE_ARGS="-DFIND_UCXX_CPP=ON;-DCMAKE_INSTALL_LIBDIR=ucxx/lib64;-DCMAKE_INSTALL_INCLUDEDIR=ucxx/include" \
python -m pip wheel "${package_dir}"/ -w "${package_dir}"/dist -vvv --no-deps --disable-pip-version-check

python -m auditwheel repair -w ${package_dir}/final_dist --exclude "libucp.so.0" --exclude "libucxx.so" ${package_dir}/dist/*

RAPIDS_PY_WHEEL_NAME="ucxx_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 ${package_dir}/final_dist
KyleFromNVIDIA marked this conversation as resolved.
Show resolved Hide resolved
else
echo "Unknown package '${package_name}'"
Expand Down
8 changes: 8 additions & 0 deletions ci/build_wheel_libucxx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.

set -euo pipefail

package_dir="python/libucxx"

./ci/build_wheel.sh libucxx ${package_dir}
73 changes: 69 additions & 4 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,48 @@ files:
includes:
- docs
- py_version
py_rapids_build_ucxx:
py_build_libucxx:
output: pyproject
pyproject_dir: python/ucxx
pyproject_dir: python/libucxx
extras:
table: build-system
includes:
- rapids_build_skbuild
py_rapids_build_libucxx:
output: pyproject
pyproject_dir: python/libucxx
extras:
table: tool.rapids-build-backend
key: requires
includes:
- build_cpp
- depends_on_librmm
KyleFromNVIDIA marked this conversation as resolved.
Show resolved Hide resolved
- depends_on_ucx_build
py_run_libucxx:
output: pyproject
pyproject_dir: python/libucxx
extras:
table: project
includes:
- depends_on_ucx_run
py_build_ucxx:
output: pyproject
pyproject_dir: python/ucxx
extras:
table: build-system
includes:
- rapids_build_skbuild
py_rapids_build_ucxx:
output: pyproject
pyproject_dir: python/ucxx
extras:
table: tool.rapids-build-backend
key: requires
includes:
- build_python_ucxx
- depends_on_librmm
- depends_on_libucxx
- depends_on_rmm
- depends_on_ucx_build
py_run_ucxx:
output: pyproject
pyproject_dir: python/ucxx
Expand All @@ -81,7 +106,6 @@ files:
includes:
- run_python_ucxx
- depends_on_rmm
- depends_on_ucx_run
py_test_ucxx:
output: pyproject
pyproject_dir: python/ucxx
Expand Down Expand Up @@ -135,6 +159,10 @@ dependencies:
- librmm==24.10.*,>=0.0.0a0
- ninja
- spdlog>=1.12.0,<1.13
- output_types: [requirements, pyproject]
packages:
- *cmake_ver
- ninja
build_python_ucxx:
common:
- output_types: [conda, requirements, pyproject]
Expand Down Expand Up @@ -298,6 +326,26 @@ dependencies:
packages: &cupy_packages_cu11
- cupy-cuda11x>=12.0.0
- {matrix: null, packages: *cupy_packages_cu11}
depends_on_librmm:
common:
- output_types: conda
packages:
- &librmm_conda librmm==24.10.*,>=0.0.0a0
KyleFromNVIDIA marked this conversation as resolved.
Show resolved Hide resolved
- output_types: requirements
packages:
# pip recognizes the index as a global option for the requirements.txt file
- --extra-index-url=https://pypi.nvidia.com
- --extra-index-url=https://pypi.anaconda.org/rapidsai-wheels-nightly/simple
specific:
- output_types: [requirements, pyproject]
matrices:
- matrix: {cuda: "12.*"}
packages:
- librmm-cu12==24.10.*,>=0.0.0a0
- matrix: {cuda: "11.*"}
packages:
- librmm-cu11==24.10.*,>=0.0.0a0
- {matrix: null, packages: [*librmm_conda]}
depends_on_rmm:
common:
- output_types: conda
Expand Down Expand Up @@ -346,6 +394,23 @@ dependencies:
packages:
- cudf-cu11==24.10.*,>=0.0.0a0
- {matrix: null, packages: [*cudf_unsuffixed]}
depends_on_libucxx:
specific:
- output_types: [requirements, pyproject]
matrices:
- matrix:
cuda: "12.*"
cuda_suffixed: "true"
packages:
- libucxx-cu12==0.40.*,>=0.0.0a0
KyleFromNVIDIA marked this conversation as resolved.
Show resolved Hide resolved
- matrix:
cuda: "11.*"
cuda_suffixed: "true"
packages:
- libucxx-cu11==0.40.*,>=0.0.0a0
- matrix:
packages:
- libucxx==0.40.*,>=0.0.0a0
depends_on_ucxx:
common:
- output_types: conda
Expand Down
50 changes: 50 additions & 0 deletions python/libucxx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# =============================================================================
# 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.
# =============================================================================

cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)

file(READ "${CMAKE_CURRENT_LIST_DIR}/../../VERSION" _version_contents)
if(_version_contents MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$")
set(ucxx_version "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
else()
string(REPLACE "\n" "\n " _version_contents_formatted "${_version_contents}")
message(FATAL_ERROR "Could not determine ucxx version. Contents of VERSION file:\n ${_version_contents_formatted}")
endif()

include(../../fetch_rapids.cmake)
include(rapids-cpm)
include(rapids-cuda)
rapids_cuda_init_architectures(libucxx-python)
rapids_cpm_init()

project(
libucxx-python
VERSION "${ucxx_version}"
LANGUAGES CXX
)

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

if(ucxx_FOUND)
return()
endif()

unset(ucxx_FOUND)

set(BUILD_TESTS OFF)
set(BUILD_BENCHMARKS OFF)

add_subdirectory(../../cpp ucxx-cpp)
1 change: 1 addition & 0 deletions python/libucxx/LICENSE
1 change: 1 addition & 0 deletions python/libucxx/README.md
1 change: 1 addition & 0 deletions python/libucxx/libucxx/VERSION
18 changes: 18 additions & 0 deletions python/libucxx/libucxx/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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 libucxx._version import __git_commit__, __version__
from libucxx.load import load_library

__all__ = ["load_library", "__git_commit__", "__version__"]
30 changes: 30 additions & 0 deletions python/libucxx/libucxx/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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(__package__).joinpath("VERSION").read_text().strip()
)
try:
__git_commit__ = (
importlib.resources.files(__package__)
.joinpath("GIT_COMMIT")
.read_text()
.strip()
)
except FileNotFoundError:
__git_commit__ = ""

__all__ = ["__git_commit__", "__version__"]
54 changes: 54 additions & 0 deletions python/libucxx/libucxx/load.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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 ctypes
import os


def load_library():
# If libucx was installed as a wheel, we must request it to load the library
# symbols. Otherwise, we assume that the library was installed in a system path
# that ld can find.
try:
import libucx
except ModuleNotFoundError:
pass
else:
libucx.load_library()
del libucx

# Dynamically load libucxx.so. Prefer a system library if one is present to
# avoid clobbering symbols that other packages might expect, but if no
# other library is present use the one in the wheel.
libucxx_lib = None
try:
libucxx_lib = ctypes.CDLL("libucxx.so", ctypes.RTLD_GLOBAL)
except OSError:
# If neither of these directories contain the library, we assume we are in an
# environment where the C++ library is already installed somewhere else and the
# CMake build of the libucxx Python package was a no-op. Note that this approach
# won't work for real editable installs of the libucxx package, but that's not a
# use case I think we need to support. scikit-build-core has limited support for
# importlib.resources so there isn't a clean way to support that case yet.
for lib_dir in ("lib", "lib64"):
if os.path.isfile(
lib := os.path.join(os.path.dirname(__file__), lib_dir, "libucxx.so")
):
libucxx_lib = ctypes.CDLL(lib, ctypes.RTLD_GLOBAL)
break

# The caller almost never needs to do anything with this library, but no
# harm in offering the option since this object at least provides a handle
# to inspect where libucxx was loaded from.
return libucxx_lib
Loading
Loading