Skip to content

Commit 777b106

Browse files
authored
Merge branch 'main' into replace-stream-attribute-with-method
2 parents 2db4743 + ee8d7cd commit 777b106

File tree

19 files changed

+187
-89
lines changed

19 files changed

+187
-89
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/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ Differences between these options are described in [Installation](https://nvidia
1919
CUDA Python is supported on all platforms that CUDA is supported. Specific dependencies are as follows:
2020

2121
* Driver: Linux (450.80.02 or later) Windows (456.38 or later)
22-
* CUDA Toolkit 12.0 to 12.6
22+
* CUDA Toolkit 12.x
2323

24-
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.
24+
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).
2525

2626
### Supported Python Versions
2727

@@ -63,8 +63,8 @@ Latest dependencies can be found in [requirements.txt](https://github.com/NVIDIA
6363

6464
Multiple testing options are available:
6565

66-
* Cython Unit Tests
6766
* Python Unit Tests
67+
* Cython Unit Tests
6868
* Samples
6969
* Benchmark
7070

@@ -73,18 +73,18 @@ Multiple testing options are available:
7373
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.
7474

7575
To run these tests:
76-
* `python -m pytest tests/` against local builds
76+
* `python -m pytest tests/` against editable installations
7777
* `pytest tests/` against installed packages
7878

7979
### Cython Unit Tests
8080

81-
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:
81+
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:
8282

8383
1. Setup environment variable `CUDA_HOME` with the path to the CUDA Toolkit installation.
8484
2. Run `build_tests` script located in `test/cython` appropriate to your platform. This will both cythonize the tests and build them.
8585

8686
To run these tests:
87-
* `python -m pytest tests/cython/` against local builds
87+
* `python -m pytest tests/cython/` against editable installations
8888
* `pytest tests/cython/` against installed packages
8989

9090
### Samples
@@ -102,13 +102,13 @@ In addition, extra examples are included:
102102
wrappers of the driver API.
103103

104104
To run these samples:
105-
* `python -m pytest tests/cython/` against local builds
105+
* `python -m pytest tests/cython/` against editable installations
106106
* `pytest tests/cython/` against installed packages
107107

108108
### Benchmark (WIP)
109109

110110
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.
111111

112112
The intended way to run these benchmarks was:
113-
* `python -m pytest --benchmark-only benchmark/` against local builds
113+
* `python -m pytest --benchmark-only benchmark/` against editable installations
114114
* `pytest --benchmark-only benchmark/` against installed packages

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/docs/source/install.md

Lines changed: 20 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,91 +2,51 @@
22

33
## Runtime Requirements
44

5-
CUDA Python is supported on all platforms that CUDA is supported. Specific
6-
dependencies are as follows:
5+
`cuda.bindings` supports the same platforms as CUDA. Runtime dependencies are:
76

87
* Driver: Linux (450.80.02 or later) Windows (456.38 or later)
9-
* CUDA Toolkit 12.0 to 12.6
8+
* CUDA Toolkit 12.x
109

11-
```{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.
10+
```{note}
11+
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).
1212
```
1313

1414
## Installing from PyPI
1515

16-
```{code-block} shell
17-
pip install cuda-python
16+
```console
17+
$ pip install cuda-python
1818
```
1919

2020
## Installing from Conda
2121

22-
```{code-block} shell
23-
conda install -c nvidia cuda-python
22+
```console
23+
$ conda install -c conda-forge cuda-python
2424
```
2525

26-
Conda packages are assigned a dependency to CUDA Toolkit:
27-
28-
* cuda-cudart (Provides CUDA headers to enable writting NVRTC kernels with CUDA types)
29-
* cuda-nvrtc (Provides NVRTC shared library)
30-
3126
## Installing from Source
3227

33-
### Build Requirements
28+
### Requirements
3429

35-
* CUDA Toolkit headers
36-
* Cython
37-
* pyclibrary
30+
* CUDA Toolkit headers[^1]
3831

39-
Remaining build and test dependencies are outlined in [requirements.txt](https://github.com/NVIDIA/cuda-python/blob/main/requirements.txt)
32+
[^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.
4033

41-
The version of CUDA Toolkit headers must match the major.minor of CUDA Python. Note that minor version compatibility will still be maintained.
34+
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:
4235

43-
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:
44-
45-
```
46-
export CUDA_HOME=/usr/local/cuda
36+
```console
37+
$ export CUDA_HOME=/usr/local/cuda
4738
```
4839

49-
### In-place
50-
51-
To compile the extension in-place, run:
52-
53-
```{code-block} shell
54-
python setup.py build_ext --inplace
40+
```{note}
41+
Only `cydriver`, `cyruntime` and `cynvrtc` are impacted by the header requirement.
5542
```
5643

57-
To compile for debugging the extension modules with gdb, pass the `--debug`
58-
argument to setup.py.
59-
60-
### Develop
44+
### Editable Install
6145

6246
You can use
6347

64-
```{code-block} shell
65-
pip install -e .
48+
```console
49+
$ pip install -v -e .
6650
```
6751

68-
to install the module as editible in your current Python environment (e.g. for
69-
testing of porting other libraries to use the binding).
70-
71-
## Build the Docs
72-
73-
```{code-block} shell
74-
conda env create -f docs_src/environment-docs.yml
75-
conda activate cuda-python-docs
76-
```
77-
Then compile and install `cuda-python` following the steps above.
78-
79-
```{code-block} shell
80-
cd docs_src
81-
make html
82-
open build/html/index.html
83-
```
84-
85-
### Publish the Docs
86-
87-
```{code-block} shell
88-
git checkout gh-pages
89-
cd docs_src
90-
make html
91-
cp -a build/html/. ../docs/
92-
```
52+
to install the module as editable in your current Python environment (e.g. for testing of porting other libraries to use the binding).

cuda_bindings/docs/source/module/nvjitlink.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
nvjitlink
22
=========
33

4+
Note
5+
----
6+
7+
The nvjitlink bindings are not supported on nvJitLink installations <12.3. Ensure the installed CUDA toolkit's nvJitLink version is >=12.3.
8+
49
Functions
510
---------
611

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/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ for more details, including how to sign your commits.
3939
## Testing
4040

4141
To run these tests:
42-
* `python -m pytest tests/` against local builds
42+
* `python -m pytest tests/` against editable installations
4343
* `pytest tests/` against installed packages

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

0 commit comments

Comments
 (0)