Skip to content

Commit

Permalink
Merge branch 'main' into update-readme
Browse files Browse the repository at this point in the history
  • Loading branch information
bdice authored Jan 12, 2024
2 parents 45c68f4 + c2353cb commit 0bb6cd2
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/actions/compute-matrix/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ runs:
"
export TEST_MATRIX="
- { CUDA_VER: '12.0.1', ARCH: 'amd64', PY_VER: '3.9', LINUX_VER: 'ubuntu18.04', gpu: 'v100', driver: 'latest' }
- { CUDA_VER: '12.0.1', ARCH: 'amd64', PY_VER: '3.10', LINUX_VER: 'ubuntu18.04', gpu: 'v100', driver: 'latest' }
- { CUDA_VER: '12.0.1', ARCH: 'amd64', PY_VER: '3.11', LINUX_VER: 'ubuntu18.04', gpu: 'v100', driver: 'latest' }
- { CUDA_VER: '12.0.1', ARCH: 'amd64', PY_VER: '3.9', LINUX_VER: 'ubuntu20.04', gpu: 'v100', driver: 'latest' }
- { CUDA_VER: '12.0.1', ARCH: 'amd64', PY_VER: '3.10', LINUX_VER: 'ubuntu20.04', gpu: 'v100', driver: 'latest' }
- { CUDA_VER: '12.0.1', ARCH: 'amd64', PY_VER: '3.11', LINUX_VER: 'ubuntu20.04', gpu: 'v100', driver: 'latest' }
- { CUDA_VER: '12.0.1', ARCH: 'arm64', PY_VER: '3.9', LINUX_VER: 'ubuntu20.04', gpu: 'a100', driver: 'latest' }
- { CUDA_VER: '12.0.1', ARCH: 'arm64', PY_VER: '3.10', LINUX_VER: 'ubuntu20.04', gpu: 'a100', driver: 'latest' }
- { CUDA_VER: '12.0.1', ARCH: 'arm64', PY_VER: '3.11', LINUX_VER: 'ubuntu20.04', gpu: 'a100', driver: 'latest' }
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ jobs:
build_type: branch
script: "ci/build_wheel.sh"
matrix_filter: ${{ needs.compute-matrix.outputs.BUILD_MATRIX }}
build-conda:
needs:
- compute-matrix
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
build_type: pull-request
build_script: "ci/build_conda.sh"
matrix_filter: ${{ needs.compute-matrix.outputs.BUILD_MATRIX }}
publish-wheels:
needs:
- build-wheels
Expand All @@ -39,3 +47,13 @@ jobs:
sha: ${{ inputs.sha }}
date: ${{ inputs.date }}
package-name: pynvjitlink
publish-conda:
needs:
- build-conda
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
build_type: ${{ inputs.build_type || 'branch' }}
branch: ${{ inputs.branch }}
date: ${{ inputs.date }}
sha: ${{ inputs.sha }}
19 changes: 19 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
needs:
- checks
- compute-matrix
- build-conda
- test-conda
- build-wheels
- test-wheels
secrets: inherit
Expand All @@ -34,6 +36,23 @@ jobs:
- name: Compute Build Matrix
id: compute-matrix
uses: ./.github/actions/compute-matrix
build-conda:
needs:
- compute-matrix
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
build_type: pull-request
build_script: "ci/build_conda.sh"
matrix_filter: ${{ needs.compute-matrix.outputs.BUILD_MATRIX }}
test-conda:
needs:
- build-conda
- compute-matrix
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
build_type: pull-request
test_script: "ci/test_conda.sh"
matrix_filter: ${{ needs.compute-matrix.outputs.TEST_MATRIX }}
build-wheels:
needs:
- compute-matrix
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ find_package(Python COMPONENTS Interpreter Development REQUIRED)
Python_add_library(_nvjitlinklib MODULE pynvjitlink/_nvjitlinklib.cpp WITH_SOABI)

find_package(
CUDAToolkit 12.3 REQUIRED
# Require CUDA 12.2 Update 2 to avoid nvjitlink bugs
CUDAToolkit 12.2.140 REQUIRED
)
target_link_libraries(_nvjitlinklib PRIVATE CUDA::nvJitLink_static CUDA::nvptxcompiler_static)

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

set -euo pipefail

source rapids-env-update

export CMAKE_GENERATOR=Ninja

rapids-print-env

rapids-logger "Begin py build"

rapids-conda-retry mambabuild conda/recipes/pynvjitlink

rapids-upload-conda-to-s3 python
15 changes: 12 additions & 3 deletions ci/build_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@ set -euo pipefail
rapids-logger "Install CUDA Toolkit"
source "$(dirname "$0")/install_latest_cuda_toolkit.sh"

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}"

# Patch project metadata files to include the CUDA version suffix.
sed -i "s/^name = \"pynvjitlink\"/name = \"pynvjitlink${PACKAGE_CUDA_SUFFIX}\"/g" pyproject.toml

rapids-logger "Build wheel"
mkdir -p ./wheel-build
pip wheel . --wheel-dir=./wheel-build -vvv
mkdir -p ./dist
python -m pip wheel . --wheel-dir=./dist -vvv --disable-pip-version-check --no-deps

rapids-logger "Upload Wheel"
RAPIDS_PY_WHEEL_NAME="pynvjitlink-cu12" rapids-upload-wheels-to-s3 ./wheel-build
RAPIDS_PY_WHEEL_NAME="pynvjitlink_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 ./dist
54 changes: 54 additions & 0 deletions ci/test_conda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION

set -euo pipefail

. /opt/conda/etc/profile.d/conda.sh

rapids-logger "Generate testing dependencies"
# TODO: Replace with rapids-dependency-file-generator
rapids-mamba-retry create -n test \
c-compiler \
cxx-compiler \
cuda-nvcc \
cuda-version=${RAPIDS_CUDA_VERSION%.*} \
"numba>=0.57" \
make \
pytest \
python=${RAPIDS_PY_VERSION}

# Temporarily allow unbound variables for conda activation.
set +u
conda activate test
set -u

PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python)
RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"}/
mkdir -p "${RAPIDS_TESTS_DIR}"

rapids-print-env

rapids-mamba-retry install \
--channel "${PYTHON_CHANNEL}" \
pynvjitlink

rapids-logger "Build Tests"
pushd test_binary_generation
make
popd

rapids-logger "Check GPU usage"
nvidia-smi

EXITCODE=0
trap "EXITCODE=1" ERR
set +e

rapids-logger "pytest pynvjitlink"
pytest \
--cache-clear \
--junitxml="${RAPIDS_TESTS_DIR}/junit-pynvjitlink.xml" \
-v

rapids-logger "Test script exiting with value: $EXITCODE"
exit ${EXITCODE}
14 changes: 10 additions & 4 deletions ci/test_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@
set -euo pipefail

rapids-logger "Download Wheel"
RAPIDS_PY_WHEEL_NAME="pynvjitlink-cu12" rapids-download-wheels-from-s3 ./wheel-build/
RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"
RAPIDS_PY_WHEEL_NAME="pynvjitlink_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 ./dist/

# 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}"

rapids-logger "Install wheel"
pip install --find-links ./wheel-build pynvjitlink-cu12
pip install --find-links ./dist pynvjitlink${PACKAGE_CUDA_SUFFIX}

rapids-logger "Build Tests"
cd test_binary_generation && make
pushd test_binary_generation
make
popd

rapids-logger "Run Tests"
cd ..
pip install pytest
pytest pynvjitlink/tests
11 changes: 11 additions & 0 deletions conda/recipes/pynvjitlink/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
c_compiler_version:
- 11

cxx_compiler_version:
- 11

cuda_compiler:
- cuda-nvcc

cuda_compiler_version:
- 12.2
56 changes: 56 additions & 0 deletions conda/recipes/pynvjitlink/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright (c) 2018-2024, NVIDIA CORPORATION.

{% set data = load_file_data("pyproject.toml") %}
{% set project_data = data.get("project") %}
{% set project_urls = project_data["urls"] %}

{% if cuda_compiler_version %}
{% set cuda_major = cuda_compiler_version.split(".")[0]|int %}
{% set cuda_minor = cuda_compiler_version.split(".")[1]|int %}
{% else %}
{% set cuda_major = 0 %}
{% set cuda_minor = 0 %}
{% endif %}

package:
name: pynvjitlink
version: {{ project_data["version"] }}

source:
path: ../../..

build:
script:
- {{ PYTHON }} -m pip install . -vv
ignore_run_exports_from:
- libnvjitlink-dev

requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- {{ compiler('cuda') }}
- cmake >=3.26.4
- ninja
- sysroot_{{ target_platform }} 2.17
host:
- libnvjitlink-dev
- libnvjitlink-static
- cuda-version {{ cuda_compiler_version }}
- python
- pip
- scikit-build-core
run:
- python
- numba >=0.57
- {{ pin_compatible('cuda-version', min_pin='x', upper_bound=(cuda_major ~ "." ~ (cuda_minor + 1))) }}

about:
home: {{ project_urls["Homepage"] }}
dev_url: {{ project_urls["Repository"] }}
doc_url: {{ project_urls["Documentation"] }}
license: {{ project_data["license"]["text"] }}
license_family: Apache
license_file: LICENSE
license_url: {{ project_urls["License"] }}
summary: nvJitLink Python binding
5 changes: 5 additions & 0 deletions pynvjitlink/tests/test_pynvjitlink_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ def test_add_cubin_with_fatbin_error(device_functions_fatbin):
nvjitlinker.add_cubin(device_functions_fatbin, name)


@pytest.mark.xfail(
reason="Fails in conda due to using CUDA 12.2u2. This should be fixed "
"when requiring CUDA 12.3 nvjitlink library. See: "
"https://github.com/rapidsai/pynvjitlink/pull/33#issuecomment-1885182905"
)
def test_add_fatbin_with_cubin_error(device_functions_cubin):
nvjitlinker = NvJitLinker("-arch=sm_75")
name = "test_device_functions.cubin"
Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ requires = ["scikit-build-core"]
build-backend = "scikit_build_core.build"

[project]
name = "pynvjitlink-cu12"
name = "pynvjitlink"
version = "0.1.6"
description = "nvJitLink Python binding"
readme = { file = "README.md", content-type = "text/markdown" }
Expand All @@ -20,6 +20,12 @@ authors = [
license = { text = "Apache 2.0" }
requires-python = ">=3.9"

[project.urls]
Homepage = "https://rapids.ai/"
Documentation = "https://github.com/rapidsai/pynvjitlink/blob/main/README.md"
Repository = "https://github.com/rapidsai/pynvjitlink"
License = "https://github.com/rapidsai/pynvjitlink/blob/main/LICENSE"

[tool.setuptools]
license-files = ["LICENSE"]

Expand Down

0 comments on commit 0bb6cd2

Please sign in to comment.