Skip to content

Commit

Permalink
add cuda-python pure Python wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
leofang committed Jan 13, 2025
1 parent 66739e1 commit a4a6721
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 10 deletions.
61 changes: 52 additions & 9 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
# (matrix.host-platform == 'win-64' && 'windows-amd64-cpu8') }}
outputs:
BUILD_CTK_VER: ${{ steps.pass_env.outputs.CUDA_VERSION }}
defaults:
run:
shell: bash --noprofile --norc -xeuo pipefail {0}
steps:
- name: Checkout ${{ github.event.repository.name }}
uses: actions/checkout@v4
Expand All @@ -63,7 +66,6 @@ jobs:
uses: ilammy/msvc-dev-cmd@v1

- name: Set environment variables
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
PYTHON_VERSION_FORMATTED=$(echo '${{ matrix.python-version }}' | tr -d '.')
if [[ "${{ matrix.host-platform }}" == linux* ]]; then
Expand All @@ -81,7 +83,6 @@ jobs:
echo "CIBW_BUILD=${CIBW_BUILD}" >> $GITHUB_ENV

- name: Dump environment
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
env
Expand Down Expand Up @@ -110,7 +111,6 @@ jobs:
output-dir: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}

- name: List the cuda.bindings artifacts directory
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
if [[ "${{ matrix.host-platform }}" == win* ]]; then
export CHOWN=chown
Expand All @@ -122,8 +122,8 @@ jobs:
# TODO: enable this after NVIDIA/cuda-python#297 is resolved
# - name: Check cuda.bindings wheel
# shell: bash --noprofile --norc -xeuo pipefail {0}
# run: |
# pip install twine
# twine check ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl

- name: Upload cuda.bindings build artifacts
Expand All @@ -132,7 +132,36 @@ jobs:
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
if-no-files-found: error
overwrite: 'true'

# upload-artifact's "overwrite: true" option has a race condition among parallel
# jobs, so we let job 0 do the work
- name: Build and check cuda-python wheel
if: ${{ strategy.job-index == 0 }}
run: |
pushd cuda_python
pip wheel -v --no-deps .
pip install twine # TODO: remove me (see above)
twine check *.whl
popd
- name: List the cuda-python artifacts directory
if: ${{ strategy.job-index == 0 }}
run: |
if [[ "${{ matrix.host-platform }}" == win* ]]; then
export CHOWN=chown
else
export CHOWN="sudo chown"
fi
$CHOWN -R $(whoami) cuda_python/*.whl
ls -lahR cuda_python
- name: Upload cuda-python build artifacts
if: ${{ strategy.job-index == 0 }}
uses: actions/upload-artifact@v4
with:
name: cuda-python-wheel
path: cuda_python/*.whl
if-no-files-found: error

- name: Pass environment variables to the next runner
id: pass_env
Expand Down Expand Up @@ -186,9 +215,11 @@ jobs:
NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }}
needs:
- build
defaults:
run:
shell: bash --noprofile --norc -xeuo pipefail {0}
steps:
- name: Ensure GPU is working
shell: bash --noprofile --norc -xeuo pipefail {0}
run: nvidia-smi

- name: Checkout ${{ github.event.repository.name }}
Expand All @@ -198,7 +229,6 @@ jobs:
ref: ${{ github.head_ref || github.ref_name }}

- name: Set environment variables
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
PYTHON_VERSION_FORMATTED=$(echo '${{ matrix.python-version }}' | tr -d '.')
if [[ "${{ matrix.host-platform }}" == linux* ]]; then
Expand All @@ -221,14 +251,24 @@ jobs:
echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV
echo "SKIP_CUDA_BINDINGS_TEST=${SKIP_CUDA_BINDINGS_TEST}" >> $GITHUB_ENV
- name: Download cuda-python build artifacts
uses: actions/download-artifact@v4
with:
name: cuda-python-wheel
path: .

- name: Display structure of downloaded cuda-python artifacts
run: |
pwd
ls -lahR .
- name: Download cuda.bindings build artifacts
uses: actions/download-artifact@v4
with:
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}

- name: Display structure of downloaded cuda.bindings artifacts
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
pwd
ls -lahR $CUDA_BINDINGS_ARTIFACTS_DIR
Expand All @@ -251,7 +291,6 @@ jobs:

- name: Run cuda.bindings tests
if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0' }}
shell: bash --noprofile --norc -xeuo pipefail {0}
run: |
pushd "${CUDA_BINDINGS_ARTIFACTS_DIR}"
if [[ "${{ matrix.local-ctk }}" == 1 ]]; then
Expand Down Expand Up @@ -280,6 +319,10 @@ jobs:
fi
popd
- name: Ensure cuda-python installable
run: |
pip install cuda_python*.whl
checks:
name: Check job status
permissions:
Expand Down
2 changes: 1 addition & 1 deletion cuda_bindings/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ requires = ["setuptools", "cython", "pyclibrary"]
build-backend = "setuptools.build_meta"

[project]
name = "cuda-python"
name = "cuda-bindings"
description = "Python bindings for CUDA"
authors = [{name = "NVIDIA Corporation", email = "[email protected]"},]
license = {file = "LICENSE"}
Expand Down
1 change: 1 addition & 0 deletions cuda_python/LICENSE
1 change: 1 addition & 0 deletions cuda_python/README.md
41 changes: 41 additions & 0 deletions cuda_python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2023-2025 NVIDIA Corporation. All rights reserved.
#
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE

[build-system]
requires = ["setuptools",]
build-backend = "setuptools.build_meta"

[project]
name = "cuda-python"
description = "CUDA Python: Performance meets Productivity"
readme = {file = "README.md", content-type = "text/markdown"}
authors = [{name = "NVIDIA Corporation", email = "[email protected]"},]
license = {file = "LICENSE"}
classifiers = [
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
"Topic :: Software Development :: Libraries",
"Topic :: Education",
"Topic :: Scientific/Engineering",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Intended Audience :: End Users/Desktop",
"License :: Other/Proprietary License",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Environment :: GPU :: NVIDIA CUDA",
"Environment :: GPU :: NVIDIA CUDA :: 12",
]
dynamic = ["version", "dependencies"]

[project.urls]
homepage = "https://nvidia.github.io/cuda-python/"
documentation = "https://nvidia.github.io/cuda-python/"
repository = "https://github.com/NVIDIA/cuda-python/"
issues = "https://github.com/NVIDIA/cuda-python/issues/"
20 changes: 20 additions & 0 deletions cuda_python/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
#
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE

from setuptools import setup

# We want to keep the version in sync with cuda.bindings, but setuptools would not let
# us to refer to any files outside of the project root, so we have to employ our own
# run-time lookup using setup()...
with open("../cuda_bindings/cuda/bindings/_version.py") as f:
exec(f.read())
version = __version__ # noqa: F821
del __version__ # noqa: F821

setup(
version=version,
install_requires=[
f"cuda-bindings~={version}",
],
)

0 comments on commit a4a6721

Please sign in to comment.