From b139153efc3eb8d51ab7984f01ee7190d95989d4 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Mon, 6 Jan 2025 05:16:38 +0000 Subject: [PATCH 01/15] make cuda-python a pure Python wheel --- cuda_python/LICENSE | 1 + cuda_python/README.md | 1 + cuda_python/pyproject.toml | 44 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 120000 cuda_python/LICENSE create mode 120000 cuda_python/README.md create mode 100644 cuda_python/pyproject.toml diff --git a/cuda_python/LICENSE b/cuda_python/LICENSE new file mode 120000 index 00000000..ea5b6064 --- /dev/null +++ b/cuda_python/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/cuda_python/README.md b/cuda_python/README.md new file mode 120000 index 00000000..32d46ee8 --- /dev/null +++ b/cuda_python/README.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file diff --git a/cuda_python/pyproject.toml b/cuda_python/pyproject.toml new file mode 100644 index 00000000..0e01d103 --- /dev/null +++ b/cuda_python/pyproject.toml @@ -0,0 +1,44 @@ +# 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" +version = "12.6.3" +description = "CUDA Python: Performance meets Productivity" +readme = {file = "README.md", content-type = "text/markdown"} +authors = [{name = "NVIDIA Corporation", email = "cuda-python-conduct@nvidia.com"},] +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", +] +dependencies = [ + "cuda-bindings~=12.6.3", +] + +[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/" From 45b1bfdf21bad30f33cf69c36ca7bf926e2f127e Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Mon, 6 Jan 2025 05:17:46 +0000 Subject: [PATCH 02/15] create cuda-bindings 12.6.3 --- cuda_bindings/cuda/bindings/_version.py | 2 +- cuda_bindings/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cuda_bindings/cuda/bindings/_version.py b/cuda_bindings/cuda/bindings/_version.py index 0f781bd1..c144fb2c 100644 --- a/cuda_bindings/cuda/bindings/_version.py +++ b/cuda_bindings/cuda/bindings/_version.py @@ -6,4 +6,4 @@ # this software and related documentation outside the terms of the EULA # is strictly prohibited. -__version__ = "12.6.2.post1" +__version__ = "12.6.3" diff --git a/cuda_bindings/pyproject.toml b/cuda_bindings/pyproject.toml index 12de0ae8..dc8fe397 100644 --- a/cuda_bindings/pyproject.toml +++ b/cuda_bindings/pyproject.toml @@ -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 = "cuda-python-conduct@nvidia.com"},] license = {file = "LICENSE"} From a1b445cf3dd5c05ecbbcb838d27c260e1a218cd8 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Mon, 6 Jan 2025 05:34:12 +0000 Subject: [PATCH 03/15] update CI to build/test the meta wheel --- .github/workflows/build-and-test.yml | 58 ++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 4eb0df75..d63edea4 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -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 @@ -62,7 +65,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 @@ -82,7 +84,6 @@ jobs: echo "CIBW_BUILD=${CIBW_BUILD}" >> $GITHUB_ENV - name: Dump environment - shell: bash --noprofile --norc -xeuo pipefail {0} run: | env @@ -97,7 +98,6 @@ jobs: output-dir: ${{ env.CUDA_CORE_ARTIFACTS_DIR }} - name: List the cuda.core artifacts directory - shell: bash --noprofile --norc -xeuo pipefail {0} run: | if [[ "${{ matrix.host-platform }}" == win* ]]; then export CHOWN=chown @@ -108,7 +108,6 @@ jobs: ls -lahR ${{ env.CUDA_CORE_ARTIFACTS_DIR }} - name: Check cuda.core wheel - shell: bash --noprofile --norc -xeuo pipefail {0} run: | pip install twine twine check ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl @@ -146,7 +145,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 @@ -158,7 +156,6 @@ jobs: # TODO: enable this after NVIDIA/cuda-python#297 is resolved # - name: Check cuda.bindings wheel - # shell: bash --noprofile --norc -xeuo pipefail {0} # run: | # twine check ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl @@ -170,6 +167,31 @@ jobs: if-no-files-found: error overwrite: 'true' + - name: Build and check cuda-python wheel + run: | + pushd cuda_python + pip wheel -v --no-deps . + twine check *.whl + popd + + - name: List the cuda-python artifacts directory + 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.bindings build artifacts + uses: actions/upload-artifact@v4 + with: + name: cuda-python-wheel + path: cuda_python/*.whl + if-no-files-found: error + overwrite: 'true' + - name: Pass environment variables to the next runner id: pass_env run: | @@ -221,9 +243,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 }} @@ -232,7 +256,6 @@ jobs: fetch-depth: 0 - 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 @@ -257,6 +280,17 @@ 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: @@ -264,7 +298,6 @@ jobs: 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 @@ -276,7 +309,6 @@ jobs: path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }} - name: Display structure of downloaded cuda.core build artifacts - shell: bash --noprofile --norc -xeuo pipefail {0} run: | pwd ls -lahR $CUDA_CORE_ARTIFACTS_DIR @@ -295,7 +327,6 @@ jobs: - name: Run cuda.bindings tests if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0' }} - shell: bash --noprofile --norc -xeuo pipefail {0} run: | ls $CUDA_PATH @@ -311,7 +342,6 @@ jobs: popd - name: Run cuda.core tests - shell: bash --noprofile --norc -xeuo pipefail {0} run: | if [[ ${{ matrix.python-version }} == "3.13" ]]; then # TODO: remove this hack once cuda-python has a cp313 build @@ -333,6 +363,10 @@ jobs: pytest -rxXs tests/ popd + - name: Ensure cuda-python installable + run: | + pip install cuda_python*.whl + doc: name: Docs # The build stage could fail but we want the CI to keep moving. From b647dfc0ec3fd28f1b2b1efcdf86776f8e509840 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Sun, 12 Jan 2025 14:44:51 -0500 Subject: [PATCH 04/15] cuda-core needs to depend on cuda-bindings --- cuda_core/pyproject.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cuda_core/pyproject.toml b/cuda_core/pyproject.toml index 6573d911..8d7bc74a 100644 --- a/cuda_core/pyproject.toml +++ b/cuda_core/pyproject.toml @@ -47,9 +47,8 @@ dependencies = [ ] [project.optional-dependencies] -# TODO: change this once cuda-bindings is packaged, see NVIDIA/cuda-python#105 -cu11 = ["cuda-python==11.8.*"] -cu12 = ["cuda-python==12.*"] +cu11 = ["cuda-bindings==11.8.*"] +cu12 = ["cuda-bindings==12.*"] [project.urls] homepage = "https://nvidia.github.io/cuda-python/" From f47ac40cffb8e7ed309eeeafcf9c71ae13bb740c Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Sun, 12 Jan 2025 20:47:31 +0000 Subject: [PATCH 05/15] fix binding version check --- cuda_bindings/setup.py | 6 +++--- cuda_bindings/tests/test_nvjitlink.py | 4 +--- cuda_core/cuda/core/experimental/_launcher.py | 5 ++--- cuda_core/cuda/core/experimental/_module.py | 5 ++--- cuda_core/cuda/core/experimental/_utils.py | 9 +++++++++ 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/cuda_bindings/setup.py b/cuda_bindings/setup.py index 7c8725ee..38882778 100644 --- a/cuda_bindings/setup.py +++ b/cuda_bindings/setup.py @@ -308,9 +308,9 @@ def build_extension(self, ext): # Allow extensions to discover libraries at runtime # relative their wheels installation. if ext.name == "cuda.bindings._bindings.cynvrtc": - ldflag = f"-Wl,--disable-new-dtags,-rpath,$ORIGIN/../../../nvidia/cuda_nvrtc/lib" + ldflag = "-Wl,--disable-new-dtags,-rpath,$ORIGIN/../../../nvidia/cuda_nvrtc/lib" elif ext.name == "cuda.bindings._internal.nvjitlink": - ldflag = f"-Wl,--disable-new-dtags,-rpath,$ORIGIN/../../../nvidia/nvjitlink/lib" + ldflag = "-Wl,--disable-new-dtags,-rpath,$ORIGIN/../../../nvidia/nvjitlink/lib" else: ldflag = None @@ -326,7 +326,7 @@ def build_extension(self, ext): cmdclass = { "bdist_wheel": WheelsBuildExtensions, "build_ext": ParallelBuildExtensions, - } +} # ---------------------------------------------------------------------- # Setup diff --git a/cuda_bindings/tests/test_nvjitlink.py b/cuda_bindings/tests/test_nvjitlink.py index 4a2c1a6b..000ef52e 100644 --- a/cuda_bindings/tests/test_nvjitlink.py +++ b/cuda_bindings/tests/test_nvjitlink.py @@ -55,9 +55,7 @@ def ptx_header(version, arch): def check_nvjitlink_usable(): from cuda.bindings._internal import nvjitlink as inner_nvjitlink - if inner_nvjitlink._inspect_function_pointer("__nvJitLinkVersion") == 0: - return False - return True + return inner_nvjitlink._inspect_function_pointer("__nvJitLinkVersion") != 0 pytestmark = pytest.mark.skipif( diff --git a/cuda_core/cuda/core/experimental/_launcher.py b/cuda_core/cuda/core/experimental/_launcher.py index 91379d57..91b6856d 100644 --- a/cuda_core/cuda/core/experimental/_launcher.py +++ b/cuda_core/cuda/core/experimental/_launcher.py @@ -2,7 +2,6 @@ # # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE -import importlib.metadata from dataclasses import dataclass from typing import Optional, Union @@ -11,7 +10,7 @@ from cuda.core.experimental._kernel_arg_handler import ParamHolder from cuda.core.experimental._module import Kernel from cuda.core.experimental._stream import Stream -from cuda.core.experimental._utils import CUDAError, check_or_create_options, handle_return +from cuda.core.experimental._utils import CUDAError, check_or_create_options, get_binding_version, handle_return # TODO: revisit this treatment for py313t builds _inited = False @@ -25,7 +24,7 @@ def _lazy_init(): global _use_ex # binding availability depends on cuda-python version - _py_major_minor = tuple(int(v) for v in (importlib.metadata.version("cuda-python").split(".")[:2])) + _py_major_minor = get_binding_version() _driver_ver = handle_return(cuda.cuDriverGetVersion()) _use_ex = (_driver_ver >= 11080) and (_py_major_minor >= (11, 8)) _inited = True diff --git a/cuda_core/cuda/core/experimental/_module.py b/cuda_core/cuda/core/experimental/_module.py index 5dc2801b..89f31b9f 100644 --- a/cuda_core/cuda/core/experimental/_module.py +++ b/cuda_core/cuda/core/experimental/_module.py @@ -2,10 +2,9 @@ # # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE -import importlib.metadata from cuda import cuda -from cuda.core.experimental._utils import handle_return, precondition +from cuda.core.experimental._utils import get_binding_version, handle_return, precondition _backend = { "old": { @@ -30,7 +29,7 @@ def _lazy_init(): global _py_major_ver, _driver_ver, _kernel_ctypes # binding availability depends on cuda-python version - _py_major_ver = int(importlib.metadata.version("cuda-python").split(".")[0]) + _py_major_ver, _ = get_binding_version() if _py_major_ver >= 12: _backend["new"] = { "file": cuda.cuLibraryLoadFromFile, diff --git a/cuda_core/cuda/core/experimental/_utils.py b/cuda_core/cuda/core/experimental/_utils.py index 9cb47a33..b672b4ac 100644 --- a/cuda_core/cuda/core/experimental/_utils.py +++ b/cuda_core/cuda/core/experimental/_utils.py @@ -3,6 +3,7 @@ # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE import functools +import importlib.metadata from collections import namedtuple from typing import Callable, Dict @@ -134,3 +135,11 @@ def get_device_from_ctx(ctx_handle) -> int: assert ctx_handle == handle_return(cuda.cuCtxPopCurrent()) handle_return(cuda.cuCtxPushCurrent(prev_ctx)) return device_id + + +def get_binding_version(): + try: + major_minor = importlib.metadata.version("cuda-bindings").split(".")[:2] + except importlib.metadata.PackageNotFoundError: + major_minor = importlib.metadata.version("cuda-python").split(".")[:2] + return tuple(int(v) for v in major_minor) From 82adef61d454910f7c9c8175446079c5c8a5b3e3 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Sun, 12 Jan 2025 21:02:53 +0000 Subject: [PATCH 06/15] fix upload-artifact race condition --- .github/workflows/build-and-test.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 8c3824ee..0f432fb9 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -123,7 +123,6 @@ jobs: name: ${{ env.CUDA_CORE_ARTIFACT_NAME }} path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl if-no-files-found: error - overwrite: 'true' - name: Set up mini CTK uses: ./.github/actions/fetch_ctk @@ -170,9 +169,10 @@ jobs: name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }} path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl if-no-files-found: error - overwrite: 'true' + # overwrite: true 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 . @@ -180,6 +180,7 @@ jobs: popd - name: List the cuda-python artifacts directory + if: ${{ strategy.job-index == 0 }} run: | if [[ "${{ matrix.host-platform }}" == win* ]]; then export CHOWN=chown @@ -189,13 +190,13 @@ jobs: $CHOWN -R $(whoami) cuda_python/*.whl ls -lahR cuda_python - - name: Upload cuda.bindings build artifacts + - 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 - overwrite: 'true' - name: Pass environment variables to the next runner id: pass_env From 94ba0b7f524fa7e5fe1821aebd100f8d6632392b Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Sun, 12 Jan 2025 20:18:07 -0500 Subject: [PATCH 07/15] install cuda-python for doc build --- .github/workflows/build-docs.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index f88e38bf..90d1cd05 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -70,6 +70,17 @@ jobs: echo "CUDA_BINDINGS_ARTIFACT_NAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $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: @@ -102,6 +113,8 @@ jobs: pip install *.whl popd + pip install cuda_python*.whl + - name: Build all (latest) docs id: build run: | From 98189145c22d3e760ab7dc5c37c962d969ae7449 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Sun, 12 Jan 2025 20:25:34 -0500 Subject: [PATCH 08/15] update comment --- .github/workflows/build-and-test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 0f432fb9..b2b7e3b3 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -170,7 +170,8 @@ jobs: path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl if-no-files-found: error - # overwrite: true has a race condition among parallel jobs, so we let job 0 do the work + # 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: | From 188370e34eaf82ba63a90067565efa9da18ac0ff Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Sun, 12 Jan 2025 20:38:09 -0500 Subject: [PATCH 09/15] set up dynamic version/dependencies --- cuda_python/pyproject.toml | 5 +---- cuda_python/setup.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 cuda_python/setup.py diff --git a/cuda_python/pyproject.toml b/cuda_python/pyproject.toml index 0e01d103..93c68abc 100644 --- a/cuda_python/pyproject.toml +++ b/cuda_python/pyproject.toml @@ -8,7 +8,6 @@ build-backend = "setuptools.build_meta" [project] name = "cuda-python" -version = "12.6.3" description = "CUDA Python: Performance meets Productivity" readme = {file = "README.md", content-type = "text/markdown"} authors = [{name = "NVIDIA Corporation", email = "cuda-python-conduct@nvidia.com"},] @@ -33,9 +32,7 @@ classifiers = [ "Environment :: GPU :: NVIDIA CUDA", "Environment :: GPU :: NVIDIA CUDA :: 12", ] -dependencies = [ - "cuda-bindings~=12.6.3", -] +dynamic = ["version", "dependencies"] [project.urls] homepage = "https://nvidia.github.io/cuda-python/" diff --git a/cuda_python/setup.py b/cuda_python/setup.py new file mode 100644 index 00000000..3c422f91 --- /dev/null +++ b/cuda_python/setup.py @@ -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}", + ], +) From f341ec52e90ef67db44c32b75680197948213cd0 Mon Sep 17 00:00:00 2001 From: ksimpson Date: Mon, 13 Jan 2025 10:09:08 -0800 Subject: [PATCH 10/15] add a note about nvjitlink compatibility --- cuda_bindings/docs/source/module/nvjitlink.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cuda_bindings/docs/source/module/nvjitlink.rst b/cuda_bindings/docs/source/module/nvjitlink.rst index c25f11b3..79f5cd10 100644 --- a/cuda_bindings/docs/source/module/nvjitlink.rst +++ b/cuda_bindings/docs/source/module/nvjitlink.rst @@ -1,6 +1,11 @@ nvjitlink ========= +Note +---- + +The nvjitlink bindings are not supported on nvJitLink installations <12.3. Ensure the installed CUDA toolkit's nvJitLink version is >=12.3. + Functions --------- From 6bb7c0bca962778751aff459783b1844b8244f49 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Mon, 13 Jan 2025 18:19:35 +0000 Subject: [PATCH 11/15] add cuda-python[all] for passing through --- .github/workflows/test-wheel.yml | 6 +++++- cuda_python/pyproject.toml | 2 +- cuda_python/setup.py | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-wheel.yml b/.github/workflows/test-wheel.yml index 5d1974f2..0062408c 100644 --- a/.github/workflows/test-wheel.yml +++ b/.github/workflows/test-wheel.yml @@ -217,4 +217,8 @@ jobs: - name: Ensure cuda-python installable run: | - pip install cuda_python*.whl + if [[ "${{ inputs.local-ctk }}" == 1 ]]; then + pip install cuda_python*.whl + else + pip install $(ls cuda_python*.whl)[all] + fi diff --git a/cuda_python/pyproject.toml b/cuda_python/pyproject.toml index 93c68abc..9566bcf9 100644 --- a/cuda_python/pyproject.toml +++ b/cuda_python/pyproject.toml @@ -32,7 +32,7 @@ classifiers = [ "Environment :: GPU :: NVIDIA CUDA", "Environment :: GPU :: NVIDIA CUDA :: 12", ] -dynamic = ["version", "dependencies"] +dynamic = ["version", "dependencies", "optional-dependencies"] [project.urls] homepage = "https://nvidia.github.io/cuda-python/" diff --git a/cuda_python/setup.py b/cuda_python/setup.py index 3c422f91..7cddd8fd 100644 --- a/cuda_python/setup.py +++ b/cuda_python/setup.py @@ -17,4 +17,7 @@ install_requires=[ f"cuda-bindings~={version}", ], + extras_require={ + "all": [f"cuda-bindings[all]~={version}"], + }, ) From 30e6635ac868a91237462981a08ccf5e5e241451 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Mon, 13 Jan 2025 20:39:51 -0500 Subject: [PATCH 12/15] 11.8 CIs should fetch cuda-python wheel from the previous branch --- .github/workflows/test-wheel.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-wheel.yml b/.github/workflows/test-wheel.yml index 0062408c..652633d0 100644 --- a/.github/workflows/test-wheel.yml +++ b/.github/workflows/test-wheel.yml @@ -87,16 +87,12 @@ jobs: dependent_exes: "gcc jq wget" - name: Download cuda-python build artifacts + if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0'}} 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 if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0'}} uses: actions/download-artifact@v4 @@ -104,7 +100,7 @@ jobs: name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }} path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }} - - name: Download cuda.bindings build artifacts from the prior branch + - name: Download cuda-python & cuda.bindings build artifacts from the prior branch if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '1'}} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -131,6 +127,14 @@ jobs: mkdir -p "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}" mv $OLD_BASENAME/*.whl "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"/ + gh run download $LATEST_PRIOR_RUN_ID -p cuda-python-wheel -R NVIDIA/cuda-python + mv cuda-python-wheel/*.whl . + + - name: Display structure of downloaded cuda-python artifacts + run: | + pwd + ls -lahR . + - name: Display structure of downloaded cuda.bindings artifacts run: | pwd From 0bd559b0d2b6d19cd04e9dd52e20a839ae2967b4 Mon Sep 17 00:00:00 2001 From: Vladislav Zhurba Date: Thu, 9 Jan 2025 16:20:55 -0800 Subject: [PATCH 13/15] Update source installation instuctions with Cython considerations --- cuda_bindings/README.md | 2 +- cuda_bindings/docs/source/install.md | 72 +++++++++------------------- 2 files changed, 24 insertions(+), 50 deletions(-) diff --git a/cuda_bindings/README.md b/cuda_bindings/README.md index 7a2d8fc8..c563f45c 100644 --- a/cuda_bindings/README.md +++ b/cuda_bindings/README.md @@ -63,8 +63,8 @@ Latest dependencies can be found in [requirements.txt](https://github.com/NVIDIA Multiple testing options are available: -* Cython Unit Tests * Python Unit Tests +* Cython Unit Tests * Samples * Benchmark diff --git a/cuda_bindings/docs/source/install.md b/cuda_bindings/docs/source/install.md index 6bd30719..fe923750 100644 --- a/cuda_bindings/docs/source/install.md +++ b/cuda_bindings/docs/source/install.md @@ -2,91 +2,65 @@ ## Runtime Requirements -CUDA Python is supported on all platforms that CUDA is supported. Specific -dependencies are as follows: +`cuda-python` supports the same platforms as CUDA. Runtime dependencies are: * Driver: Linux (450.80.02 or later) Windows (456.38 or later) * CUDA Toolkit 12.0 to 12.6 -```{note} Only the NVRTC redistributable component is required from the CUDA Toolkit. [CUDA Toolkit Documentation](https://docs.nvidia.com/cuda/index.html) Installation Guides can be used for guidance. Note that the NVRTC component in the Toolkit can be obtained via PYPI, Conda or Local Installer. +```{note} Only the NVRTC redistributable component is required from the CUDA Toolkit. [CUDA Toolkit Documentation](https://docs.nvidia.com/cuda/index.html) Installation Guides can be used for guidance. Note that the NVRTC component in the Toolkit can be obtained via PYPI, Conda or local installers. ``` ## Installing from PyPI -```{code-block} shell -pip install cuda-python +```console +$ pip install cuda-python ``` ## Installing from Conda -```{code-block} shell -conda install -c nvidia cuda-python +```console +$ conda install -c nvidia cuda-python ``` -Conda packages are assigned a dependency to CUDA Toolkit: +Conda packages have dependencies to CUDA Toolkit components: -* cuda-cudart (Provides CUDA headers to enable writting NVRTC kernels with CUDA types) +* cuda-cudart (Provides CUDA headers to enable writing NVRTC kernels with CUDA types) * cuda-nvrtc (Provides NVRTC shared library) ## Installing from Source -### Build Requirements +### Requirements -* CUDA Toolkit headers -* Cython -* pyclibrary +* CUDA Toolkit headers[^1] +* [requirements.txt](https://github.com/NVIDIA/cuda-python/blob/main/cuda_bindings/requirements.txt) -Remaining build and test dependencies are outlined in [requirements.txt](https://github.com/NVIDIA/cuda-python/blob/main/requirements.txt) +[^1]: User projects that `cimport` CUDA symbols in Cython must also use CUDA Toolkit (CTK) types as provided by the `cuda-python` major.minor version. This results in CTK headers becoming a transitive dependency of downstream projects through CUDA Python. -The version of CUDA Toolkit headers must match the major.minor of CUDA Python. Note that minor version compatibility will still be maintained. - -During the build process, environment variable `CUDA_HOME` or `CUDA_PATH` are used to find the location of CUDA headers. In particular, if your headers are located in path `/usr/local/cuda/include`, then you should set `CUDA_HOME` as follows: +Source builds require that the provided CUDA headers are of the same major.minor version as the `cuda-python` bindings you're trying to build. Despite of this requirement, note that the minor version compatibility is still maintained. Use the `CUDA_HOME` (or `CUDA_PATH`) environment variable to specify the location of your headers. For example, if your headers are located in `/usr/local/cuda/include`, then you should set `CUDA_HOME` with: +```console +$ export CUDA_HOME=/usr/local/cuda ``` -export CUDA_HOME=/usr/local/cuda + +```{note} Only `cydriver`, `cyruntime` and `cynvrtc` are impacted by the header requirement. ``` ### In-place To compile the extension in-place, run: -```{code-block} shell -python setup.py build_ext --inplace +```console +$ python setup.py build_ext --inplace ``` -To compile for debugging the extension modules with gdb, pass the `--debug` -argument to setup.py. +To compile for debugging the extension modules with gdb, pass the `--debug` argument to setup.py. ### Develop You can use -```{code-block} shell -pip install -e . -``` - -to install the module as editible in your current Python environment (e.g. for -testing of porting other libraries to use the binding). - -## Build the Docs - -```{code-block} shell -conda env create -f docs_src/environment-docs.yml -conda activate cuda-python-docs -``` -Then compile and install `cuda-python` following the steps above. - -```{code-block} shell -cd docs_src -make html -open build/html/index.html +```console +$ pip install -e . ``` -### Publish the Docs - -```{code-block} shell -git checkout gh-pages -cd docs_src -make html -cp -a build/html/. ../docs/ -``` +to install the module as editable in your current Python environment (e.g. for testing of porting other libraries to use the binding). From fd60a05b95742c386b75a3c430324849ddd09d23 Mon Sep 17 00:00:00 2001 From: Vladislav Zhurba Date: Thu, 9 Jan 2025 16:26:14 -0800 Subject: [PATCH 14/15] Direct README.md cython test header requirements to docs --- cuda_bindings/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cuda_bindings/README.md b/cuda_bindings/README.md index c563f45c..9271ea9f 100644 --- a/cuda_bindings/README.md +++ b/cuda_bindings/README.md @@ -78,7 +78,7 @@ To run these tests: ### Cython Unit Tests -Cython tests are located in `tests/cython` and need to be built. Furthermore they need CUDA Toolkit headers matching the major-minor of CUDA Python. To build them: +Cython tests are located in `tests/cython` and need to be built. These builds have the same CUDA Toolkit header requirements as [Installing from Source](https://nvidia.github.io/cuda-python/cuda-bindings/latest/install.html#requirements) where the major.minor version must match `cuda-python`. To build them: 1. Setup environment variable `CUDA_HOME` with the path to the CUDA Toolkit installation. 2. Run `build_tests` script located in `test/cython` appropriate to your platform. This will both cythonize the tests and build them. From 083347c6d771b74af94629eaa368bec16fae5022 Mon Sep 17 00:00:00 2001 From: Vladislav Zhurba Date: Tue, 14 Jan 2025 16:17:26 -0800 Subject: [PATCH 15/15] Apply feedback --- cuda_bindings/README.md | 14 +++++------ cuda_bindings/docs/source/install.md | 36 +++++++++------------------- cuda_core/README.md | 2 +- 3 files changed, 19 insertions(+), 33 deletions(-) diff --git a/cuda_bindings/README.md b/cuda_bindings/README.md index 9271ea9f..3ece5667 100644 --- a/cuda_bindings/README.md +++ b/cuda_bindings/README.md @@ -19,9 +19,9 @@ Differences between these options are described in [Installation](https://nvidia CUDA Python is supported on all platforms that CUDA is supported. Specific dependencies are as follows: * Driver: Linux (450.80.02 or later) Windows (456.38 or later) -* CUDA Toolkit 12.0 to 12.6 +* CUDA Toolkit 12.x -Only the NVRTC redistributable component is required from the CUDA Toolkit. [CUDA Toolkit Documentation](https://docs.nvidia.com/cuda/index.html) Installation Guides can be used for guidance. Note that the NVRTC component in the Toolkit can be obtained via PYPI, Conda or Local Installer. +Only the NVRTC and nvJitLink redistributable components are required from the CUDA Toolkit, which can be obtained via PyPI, Conda, or local installers (as described in the CUDA Toolkit [Windows](https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html) and [Linux](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html) Installation Guides). ### Supported Python Versions @@ -73,18 +73,18 @@ Multiple testing options are available: Responsible for validating different binding usage patterns. Unit test `test_kernelParams.py` is particularly special since it demonstrates various approaches in setting up kernel launch parameters. To run these tests: -* `python -m pytest tests/` against local builds +* `python -m pytest tests/` against editable installations * `pytest tests/` against installed packages ### Cython Unit Tests -Cython tests are located in `tests/cython` and need to be built. These builds have the same CUDA Toolkit header requirements as [Installing from Source](https://nvidia.github.io/cuda-python/cuda-bindings/latest/install.html#requirements) where the major.minor version must match `cuda-python`. To build them: +Cython tests are located in `tests/cython` and need to be built. These builds have the same CUDA Toolkit header requirements as [Installing from Source](https://nvidia.github.io/cuda-python/cuda-bindings/latest/install.html#requirements) where the major.minor version must match `cuda.bindings`. To build them: 1. Setup environment variable `CUDA_HOME` with the path to the CUDA Toolkit installation. 2. Run `build_tests` script located in `test/cython` appropriate to your platform. This will both cythonize the tests and build them. To run these tests: -* `python -m pytest tests/cython/` against local builds +* `python -m pytest tests/cython/` against editable installations * `pytest tests/cython/` against installed packages ### Samples @@ -102,7 +102,7 @@ In addition, extra examples are included: wrappers of the driver API. To run these samples: -* `python -m pytest tests/cython/` against local builds +* `python -m pytest tests/cython/` against editable installations * `pytest tests/cython/` against installed packages ### Benchmark (WIP) @@ -110,5 +110,5 @@ To run these samples: Benchmarks were used for performance analysis during initial release of CUDA Python. Today they need to be updated the 12.x toolkit and are work in progress. The intended way to run these benchmarks was: -* `python -m pytest --benchmark-only benchmark/` against local builds +* `python -m pytest --benchmark-only benchmark/` against editable installations * `pytest --benchmark-only benchmark/` against installed packages diff --git a/cuda_bindings/docs/source/install.md b/cuda_bindings/docs/source/install.md index fe923750..b5c3e625 100644 --- a/cuda_bindings/docs/source/install.md +++ b/cuda_bindings/docs/source/install.md @@ -2,12 +2,13 @@ ## Runtime Requirements -`cuda-python` supports the same platforms as CUDA. Runtime dependencies are: +`cuda.bindings` supports the same platforms as CUDA. Runtime dependencies are: * Driver: Linux (450.80.02 or later) Windows (456.38 or later) -* CUDA Toolkit 12.0 to 12.6 +* CUDA Toolkit 12.x -```{note} Only the NVRTC redistributable component is required from the CUDA Toolkit. [CUDA Toolkit Documentation](https://docs.nvidia.com/cuda/index.html) Installation Guides can be used for guidance. Note that the NVRTC component in the Toolkit can be obtained via PYPI, Conda or local installers. +```{note} +Only the NVRTC and nvJitLink redistributable components are required from the CUDA Toolkit, which can be obtained via PyPI, Conda, or local installers (as described in the CUDA Toolkit [Windows](https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html) and [Linux](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html) Installation Guides). ``` ## Installing from PyPI @@ -19,48 +20,33 @@ $ pip install cuda-python ## Installing from Conda ```console -$ conda install -c nvidia cuda-python +$ conda install -c conda-forge cuda-python ``` -Conda packages have dependencies to CUDA Toolkit components: - -* cuda-cudart (Provides CUDA headers to enable writing NVRTC kernels with CUDA types) -* cuda-nvrtc (Provides NVRTC shared library) - ## Installing from Source ### Requirements * CUDA Toolkit headers[^1] -* [requirements.txt](https://github.com/NVIDIA/cuda-python/blob/main/cuda_bindings/requirements.txt) -[^1]: User projects that `cimport` CUDA symbols in Cython must also use CUDA Toolkit (CTK) types as provided by the `cuda-python` major.minor version. This results in CTK headers becoming a transitive dependency of downstream projects through CUDA Python. +[^1]: User projects that `cimport` CUDA symbols in Cython must also use CUDA Toolkit (CTK) types as provided by the `cuda.bindings` major.minor version. This results in CTK headers becoming a transitive dependency of downstream projects through CUDA Python. -Source builds require that the provided CUDA headers are of the same major.minor version as the `cuda-python` bindings you're trying to build. Despite of this requirement, note that the minor version compatibility is still maintained. Use the `CUDA_HOME` (or `CUDA_PATH`) environment variable to specify the location of your headers. For example, if your headers are located in `/usr/local/cuda/include`, then you should set `CUDA_HOME` with: +Source builds require that the provided CUDA headers are of the same major.minor version as the `cuda.bindings` you're trying to build. Despite this requirement, note that the minor version compatibility is still maintained. Use the `CUDA_HOME` (or `CUDA_PATH`) environment variable to specify the location of your headers. For example, if your headers are located in `/usr/local/cuda/include`, then you should set `CUDA_HOME` with: ```console $ export CUDA_HOME=/usr/local/cuda ``` -```{note} Only `cydriver`, `cyruntime` and `cynvrtc` are impacted by the header requirement. -``` - -### In-place - -To compile the extension in-place, run: - -```console -$ python setup.py build_ext --inplace +```{note} +Only `cydriver`, `cyruntime` and `cynvrtc` are impacted by the header requirement. ``` -To compile for debugging the extension modules with gdb, pass the `--debug` argument to setup.py. - -### Develop +### Editable Install You can use ```console -$ pip install -e . +$ pip install -v -e . ``` to install the module as editable in your current Python environment (e.g. for testing of porting other libraries to use the binding). diff --git a/cuda_core/README.md b/cuda_core/README.md index f66d05e1..de68bc9e 100644 --- a/cuda_core/README.md +++ b/cuda_core/README.md @@ -39,5 +39,5 @@ for more details, including how to sign your commits. ## Testing To run these tests: -* `python -m pytest tests/` against local builds +* `python -m pytest tests/` against editable installations * `pytest tests/` against installed packages