Skip to content

Commit 2ee1de9

Browse files
authored
Merge branch 'main' into add-nvjitlink-compat-note
2 parents f341ec5 + fa9b275 commit 2ee1de9

File tree

15 files changed

+153
-20
lines changed

15 files changed

+153
-20
lines changed

.github/workflows/build-and-test.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ jobs:
123123
name: ${{ env.CUDA_CORE_ARTIFACT_NAME }}
124124
path: ${{ env.CUDA_CORE_ARTIFACTS_DIR }}/*.whl
125125
if-no-files-found: error
126-
overwrite: 'true'
127126

128127
- name: Set up mini CTK
129128
uses: ./.github/actions/fetch_ctk
@@ -170,7 +169,35 @@ jobs:
170169
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
171170
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}/*.whl
172171
if-no-files-found: error
173-
overwrite: 'true'
172+
173+
# upload-artifact's "overwrite: true" option has a race condition among parallel
174+
# jobs, so we let job 0 do the work
175+
- name: Build and check cuda-python wheel
176+
if: ${{ strategy.job-index == 0 }}
177+
run: |
178+
pushd cuda_python
179+
pip wheel -v --no-deps .
180+
twine check *.whl
181+
popd
182+
183+
- name: List the cuda-python artifacts directory
184+
if: ${{ strategy.job-index == 0 }}
185+
run: |
186+
if [[ "${{ matrix.host-platform }}" == win* ]]; then
187+
export CHOWN=chown
188+
else
189+
export CHOWN="sudo chown"
190+
fi
191+
$CHOWN -R $(whoami) cuda_python/*.whl
192+
ls -lahR cuda_python
193+
194+
- name: Upload cuda-python build artifacts
195+
if: ${{ strategy.job-index == 0 }}
196+
uses: actions/upload-artifact@v4
197+
with:
198+
name: cuda-python-wheel
199+
path: cuda_python/*.whl
200+
if-no-files-found: error
174201

175202
- name: Pass environment variables to the next runner
176203
id: pass_env

.github/workflows/build-docs.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ jobs:
7070
echo "CUDA_BINDINGS_ARTIFACT_NAME=${CUDA_BINDINGS_ARTIFACT_BASENAME}-${{ github.sha }}" >> $GITHUB_ENV
7171
echo "CUDA_BINDINGS_ARTIFACTS_DIR=$(realpath "$REPO_DIR/cuda_bindings/dist")" >> $GITHUB_ENV
7272
73+
- name: Download cuda-python build artifacts
74+
uses: actions/download-artifact@v4
75+
with:
76+
name: cuda-python-wheel
77+
path: .
78+
79+
- name: Display structure of downloaded cuda-python artifacts
80+
run: |
81+
pwd
82+
ls -lahR .
83+
7384
- name: Download cuda.bindings build artifacts
7485
uses: actions/download-artifact@v4
7586
with:
@@ -102,6 +113,8 @@ jobs:
102113
pip install *.whl
103114
popd
104115
116+
pip install cuda_python*.whl
117+
105118
- name: Build all (latest) docs
106119
id: build
107120
run: |

.github/workflows/test-wheel.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,21 @@ jobs:
8686
dependencies: "build-essential jq wget"
8787
dependent_exes: "gcc jq wget"
8888

89+
- name: Download cuda-python build artifacts
90+
if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0'}}
91+
uses: actions/download-artifact@v4
92+
with:
93+
name: cuda-python-wheel
94+
path: .
95+
8996
- name: Download cuda.bindings build artifacts
9097
if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '0'}}
9198
uses: actions/download-artifact@v4
9299
with:
93100
name: ${{ env.CUDA_BINDINGS_ARTIFACT_NAME }}
94101
path: ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
95102

96-
- name: Download cuda.bindings build artifacts from the prior branch
103+
- name: Download cuda-python & cuda.bindings build artifacts from the prior branch
97104
if: ${{ env.SKIP_CUDA_BINDINGS_TEST == '1'}}
98105
env:
99106
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -120,6 +127,14 @@ jobs:
120127
mkdir -p "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"
121128
mv $OLD_BASENAME/*.whl "${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}"/
122129
130+
gh run download $LATEST_PRIOR_RUN_ID -p cuda-python-wheel -R NVIDIA/cuda-python
131+
mv cuda-python-wheel/*.whl .
132+
133+
- name: Display structure of downloaded cuda-python artifacts
134+
run: |
135+
pwd
136+
ls -lahR .
137+
123138
- name: Display structure of downloaded cuda.bindings artifacts
124139
run: |
125140
pwd
@@ -203,3 +218,11 @@ jobs:
203218
pip install -r "tests/requirements-cu${TEST_CUDA_MAJOR}.txt"
204219
pytest -rxXs tests/
205220
popd
221+
222+
- name: Ensure cuda-python installable
223+
run: |
224+
if [[ "${{ inputs.local-ctk }}" == 1 ]]; then
225+
pip install cuda_python*.whl
226+
else
227+
pip install $(ls cuda_python*.whl)[all]
228+
fi

cuda_bindings/cuda/bindings/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# this software and related documentation outside the terms of the EULA
77
# is strictly prohibited.
88

9-
__version__ = "12.6.2.post1"
9+
__version__ = "12.6.3"

cuda_bindings/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ requires = ["setuptools", "cython", "pyclibrary"]
1111
build-backend = "setuptools.build_meta"
1212

1313
[project]
14-
name = "cuda-python"
14+
name = "cuda-bindings"
1515
description = "Python bindings for CUDA"
1616
authors = [{name = "NVIDIA Corporation", email = "[email protected]"},]
1717
license = {file = "LICENSE"}

cuda_bindings/setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,9 @@ def build_extension(self, ext):
308308
# Allow extensions to discover libraries at runtime
309309
# relative their wheels installation.
310310
if ext.name == "cuda.bindings._bindings.cynvrtc":
311-
ldflag = f"-Wl,--disable-new-dtags,-rpath,$ORIGIN/../../../nvidia/cuda_nvrtc/lib"
311+
ldflag = "-Wl,--disable-new-dtags,-rpath,$ORIGIN/../../../nvidia/cuda_nvrtc/lib"
312312
elif ext.name == "cuda.bindings._internal.nvjitlink":
313-
ldflag = f"-Wl,--disable-new-dtags,-rpath,$ORIGIN/../../../nvidia/nvjitlink/lib"
313+
ldflag = "-Wl,--disable-new-dtags,-rpath,$ORIGIN/../../../nvidia/nvjitlink/lib"
314314
else:
315315
ldflag = None
316316

@@ -326,7 +326,7 @@ def build_extension(self, ext):
326326
cmdclass = {
327327
"bdist_wheel": WheelsBuildExtensions,
328328
"build_ext": ParallelBuildExtensions,
329-
}
329+
}
330330

331331
# ----------------------------------------------------------------------
332332
# Setup

cuda_bindings/tests/test_nvjitlink.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ def ptx_header(version, arch):
5555
def check_nvjitlink_usable():
5656
from cuda.bindings._internal import nvjitlink as inner_nvjitlink
5757

58-
if inner_nvjitlink._inspect_function_pointer("__nvJitLinkVersion") == 0:
59-
return False
60-
return True
58+
return inner_nvjitlink._inspect_function_pointer("__nvJitLinkVersion") != 0
6159

6260

6361
pytestmark = pytest.mark.skipif(

cuda_core/cuda/core/experimental/_launcher.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#
33
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
44

5-
import importlib.metadata
65
from dataclasses import dataclass
76
from typing import Optional, Union
87

@@ -11,7 +10,7 @@
1110
from cuda.core.experimental._kernel_arg_handler import ParamHolder
1211
from cuda.core.experimental._module import Kernel
1312
from cuda.core.experimental._stream import Stream
14-
from cuda.core.experimental._utils import CUDAError, check_or_create_options, handle_return
13+
from cuda.core.experimental._utils import CUDAError, check_or_create_options, get_binding_version, handle_return
1514

1615
# TODO: revisit this treatment for py313t builds
1716
_inited = False
@@ -25,7 +24,7 @@ def _lazy_init():
2524

2625
global _use_ex
2726
# binding availability depends on cuda-python version
28-
_py_major_minor = tuple(int(v) for v in (importlib.metadata.version("cuda-python").split(".")[:2]))
27+
_py_major_minor = get_binding_version()
2928
_driver_ver = handle_return(cuda.cuDriverGetVersion())
3029
_use_ex = (_driver_ver >= 11080) and (_py_major_minor >= (11, 8))
3130
_inited = True

cuda_core/cuda/core/experimental/_module.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
#
33
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
44

5-
import importlib.metadata
65

76
from cuda import cuda
8-
from cuda.core.experimental._utils import handle_return, precondition
7+
from cuda.core.experimental._utils import get_binding_version, handle_return, precondition
98

109
_backend = {
1110
"old": {
@@ -30,7 +29,7 @@ def _lazy_init():
3029

3130
global _py_major_ver, _driver_ver, _kernel_ctypes
3231
# binding availability depends on cuda-python version
33-
_py_major_ver = int(importlib.metadata.version("cuda-python").split(".")[0])
32+
_py_major_ver, _ = get_binding_version()
3433
if _py_major_ver >= 12:
3534
_backend["new"] = {
3635
"file": cuda.cuLibraryLoadFromFile,

cuda_core/cuda/core/experimental/_utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
44

55
import functools
6+
import importlib.metadata
67
from collections import namedtuple
78
from typing import Callable, Dict
89

@@ -134,3 +135,11 @@ def get_device_from_ctx(ctx_handle) -> int:
134135
assert ctx_handle == handle_return(cuda.cuCtxPopCurrent())
135136
handle_return(cuda.cuCtxPushCurrent(prev_ctx))
136137
return device_id
138+
139+
140+
def get_binding_version():
141+
try:
142+
major_minor = importlib.metadata.version("cuda-bindings").split(".")[:2]
143+
except importlib.metadata.PackageNotFoundError:
144+
major_minor = importlib.metadata.version("cuda-python").split(".")[:2]
145+
return tuple(int(v) for v in major_minor)

cuda_core/pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@ dependencies = [
4747
]
4848

4949
[project.optional-dependencies]
50-
# TODO: change this once cuda-bindings is packaged, see NVIDIA/cuda-python#105
51-
cu11 = ["cuda-python==11.8.*"]
52-
cu12 = ["cuda-python==12.*"]
50+
cu11 = ["cuda-bindings==11.8.*"]
51+
cu12 = ["cuda-bindings==12.*"]
5352

5453
[project.urls]
5554
homepage = "https://nvidia.github.io/cuda-python/"

cuda_python/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE

cuda_python/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../README.md

cuda_python/pyproject.toml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2023-2025 NVIDIA Corporation. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
4+
5+
[build-system]
6+
requires = ["setuptools",]
7+
build-backend = "setuptools.build_meta"
8+
9+
[project]
10+
name = "cuda-python"
11+
description = "CUDA Python: Performance meets Productivity"
12+
readme = {file = "README.md", content-type = "text/markdown"}
13+
authors = [{name = "NVIDIA Corporation", email = "[email protected]"},]
14+
license = {file = "LICENSE"}
15+
classifiers = [
16+
"Operating System :: POSIX :: Linux",
17+
"Operating System :: Microsoft :: Windows",
18+
"Topic :: Software Development :: Libraries",
19+
"Topic :: Education",
20+
"Topic :: Scientific/Engineering",
21+
"Intended Audience :: Developers",
22+
"Intended Audience :: Science/Research",
23+
"Intended Audience :: End Users/Desktop",
24+
"License :: Other/Proprietary License",
25+
"Programming Language :: Python :: 3 :: Only",
26+
"Programming Language :: Python :: 3.9",
27+
"Programming Language :: Python :: 3.10",
28+
"Programming Language :: Python :: 3.11",
29+
"Programming Language :: Python :: 3.12",
30+
"Programming Language :: Python :: 3.13",
31+
"Programming Language :: Python :: Implementation :: CPython",
32+
"Environment :: GPU :: NVIDIA CUDA",
33+
"Environment :: GPU :: NVIDIA CUDA :: 12",
34+
]
35+
dynamic = ["version", "dependencies", "optional-dependencies"]
36+
37+
[project.urls]
38+
homepage = "https://nvidia.github.io/cuda-python/"
39+
documentation = "https://nvidia.github.io/cuda-python/"
40+
repository = "https://github.com/NVIDIA/cuda-python/"
41+
issues = "https://github.com/NVIDIA/cuda-python/issues/"

cuda_python/setup.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
2+
#
3+
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
4+
5+
from setuptools import setup
6+
7+
# We want to keep the version in sync with cuda.bindings, but setuptools would not let
8+
# us to refer to any files outside of the project root, so we have to employ our own
9+
# run-time lookup using setup()...
10+
with open("../cuda_bindings/cuda/bindings/_version.py") as f:
11+
exec(f.read())
12+
version = __version__ # noqa: F821
13+
del __version__ # noqa: F821
14+
15+
setup(
16+
version=version,
17+
install_requires=[
18+
f"cuda-bindings~={version}",
19+
],
20+
extras_require={
21+
"all": [f"cuda-bindings[all]~={version}"],
22+
},
23+
)

0 commit comments

Comments
 (0)