Skip to content

Commit 6adc4ee

Browse files
authored
Merge pull request #252 from vzhurba01/cython_test_instructions
Update out-of-date (sub)package REAME files and overhaul bindings Cython test instructions
2 parents 0c426b0 + 0fbb9e8 commit 6adc4ee

File tree

9 files changed

+80
-102
lines changed

9 files changed

+80
-102
lines changed

README.md

Lines changed: 24 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,39 @@
11
# CUDA-Python
22

3-
CUDA Python is a standard set of low-level interfaces, providing full coverage of and access to the CUDA host APIs from Python. Checkout the [Overview](https://nvidia.github.io/cuda-python/overview.html) for the workflow and performance results.
3+
CUDA Python is the home for accessing NVIDIA’s CUDA platform from Python. It consists of multiple components:
44

5-
## Installing
5+
* [cuda.core](https://nvidia.github.io/cuda-python/cuda-core/latest): Pythonic access to CUDA Runtime and other core functionalities
6+
* [cuda.bindings](https://nvidia.github.io/cuda-python/cuda-bindings/latest): Low-level Python bindings to CUDA C APIs
7+
* [cuda.cooperative](https://nvidia.github.io/cccl/cuda_cooperative/): Pythonic exposure of CUB cooperative algorithms
8+
* [cuda.parallel](https://nvidia.github.io/cccl/cuda_parallel/): Pythonic exposure of Thrust parallel algorithms
69

7-
CUDA Python can be installed from:
10+
For access to NVIDIA Math Libraries, please refer to [nvmath-python](https://docs.nvidia.com/cuda/nvmath-python/latest).
811

9-
* PYPI
10-
* Conda (nvidia channel)
11-
* Source builds
12+
CUDA Python is currently undergoing an overhaul to improve existing and bring up new components. All of the previously available functionalities from the cuda-python package will continue to be available, please refer to the [cuda.bindings](https://nvidia.github.io/cuda-python/cuda-bindings/latest) documentation for installation guide and further detail.
1213

13-
There're differences in each of these options that are described further in [Installation](https://nvidia.github.io/cuda-python/install.html) documentation. Each package will guarantee minor version compatibility.
14+
## CUDA-Python as a metapackage
1415

15-
## Runtime Dependencies
16+
CUDA-Python is structured to become a metapackage that contains a collection of subpackages. Each subpackage is versioned independently, allowing installation of each component as needed.
1617

17-
CUDA Python is supported on all platforms that CUDA is supported. Specific dependencies are as follows:
18+
### Subpackage: `cuda.core`
1819

19-
* Driver: Linux (450.80.02 or later) Windows (456.38 or later)
20-
* CUDA Toolkit 12.0 to 12.6
20+
The `cuda.core` package offers idiomatic, pythonic access to CUDA Runtime and other functionalities.
2121

22-
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.
22+
The goals are to
2323

24-
### Supported Python Versions
24+
1. Provide **idiomatic (“pythonic”)** access to CUDA Driver/Runtime
25+
2. Focus on **developer productivity** by ensuring end-to-end CUDA development can be performed quickly and entirely in Python
26+
3. **Avoid homegrown** Python abstractions for CUDA for new Python GPU libraries starting from scratch
27+
4. **Ease** developer **burden of maintaining** and catching up with latest CUDA features
28+
5. **Flatten the learning curve** for current and future generations of CUDA developers
2529

26-
CUDA Python follows [NEP 29](https://numpy.org/neps/nep-0029-deprecation_policy.html) for supported Python version guarantee.
30+
### Subpackage: `cuda.bindings`
2731

28-
Before dropping support, an issue will be raised to look for feedback.
32+
The `cuda.bindings` package is a standard set of low-level interfaces, providing full coverage of and access to the CUDA host APIs from Python.
2933

30-
Source builds work for multiple Python versions, however pre-build PyPI and Conda packages are only provided for a subset:
34+
The list of available interfaces are:
3135

32-
* Python 3.9 to 3.12
33-
34-
## Testing
35-
36-
### Requirements
37-
38-
Latest dependencies can be found in [requirements.txt](https://github.com/NVIDIA/cuda-python/blob/main/requirements.txt).
39-
40-
### Unit-tests
41-
42-
You can run the included tests with:
43-
44-
```
45-
python -m pytest tests/
46-
```
47-
48-
### Benchmark
49-
50-
You can run benchmark only tests with:
51-
52-
```
53-
python -m pytest --benchmark-only benchmarks/
54-
```
55-
56-
### Samples
57-
58-
You can run the included tests with:
59-
60-
```
61-
python -m pytest examples/
62-
```
63-
64-
## Examples
65-
66-
CUDA Samples rewriten using CUDA Python are found in `examples`.
67-
68-
Custom extra included examples:
69-
70-
- `examples/extra/jit_program_test.py`: Demonstrates the use of the API to compile and
71-
launch a kernel on the device. Includes device memory allocation /
72-
deallocation, transfers between host and device, creation and usage of
73-
streams, and context management.
74-
- `examples/extra/numba_emm_plugin.py`: Implements a Numba External Memory Management
75-
plugin, showing that this CUDA Python Driver API can coexist with other
76-
wrappers of the driver API.
36+
* CUDA Driver
37+
* CUDA Runtime
38+
* NVRTC
39+
* nvJitLink

cuda_bindings/README.md

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# CUDA-Python
1+
# `cuda.bindings`: Low-level CUDA interfaces
22

3-
CUDA Python is a standard set of low-level interfaces, providing full coverage of and access to the CUDA host APIs from Python. Checkout the [Overview](https://nvidia.github.io/cuda-python/overview.html) for the workflow and performance results.
3+
CUDA Python is a standard set of low-level interfaces, providing full coverage of and access to the CUDA host APIs from Python. Checkout the [Overview](https://nvidia.github.io/cuda-python/cuda-bindings/latest/overview.html) for the workflow and performance results.
44

55
## Installing
66

@@ -10,7 +10,7 @@ CUDA Python can be installed from:
1010
* Conda (nvidia channel)
1111
* Source builds
1212

13-
There're differences in each of these options that are described further in [Installation](https://nvidia.github.io/cuda-python/install.html) documentation. Each package will guarantee minor version compatibility.
13+
Differences between these options are described in [Installation](https://nvidia.github.io/cuda-python/cuda-bindings/latest/install.html) documentation. Each package guarantees minor version compatibility.
1414

1515
## Runtime Dependencies
1616

@@ -33,53 +33,56 @@ Source builds work for multiple Python versions, however pre-build PyPI and Cond
3333

3434
## Testing
3535

36-
### Requirements
36+
Latest dependencies can be found in [requirements.txt](https://github.com/NVIDIA/cuda-python/blob/main/cuda_bindings/requirements.txt).
3737

38-
Latest dependencies can be found in [requirements.txt](https://github.com/NVIDIA/cuda-python/blob/main/requirements.txt).
38+
Multiple testing options are available:
3939

40-
### Unit-tests
40+
* Cython Unit Tests
41+
* Python Unit Tests
42+
* Samples
43+
* Benchmark
4144

42-
To run unit-tests against local builds:
43-
```
44-
python -m pytest tests/
45-
```
46-
To run unit-tests against installed builds:
47-
```
48-
pytest tests/
49-
```
45+
### Python Unit Tests
5046

51-
### Benchmark
47+
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.
5248

53-
To run unit-tests against local builds:
54-
```
55-
python -m pytest --benchmark-only benchmark/
56-
```
57-
To run unit-tests against installed builds:
58-
```
59-
pytest --benchmark-only benchmark/
60-
```
49+
To run these tests:
50+
* `python -m pytest tests/` against local builds
51+
* `pytest tests/` against installed packages
6152

62-
### Samples
53+
### Cython Unit Tests
54+
55+
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:
6356

64-
To run unit-tests against local builds:
65-
```
66-
python -m pytest benchmark/
67-
```
68-
To run unit-tests against installed builds:
69-
```
70-
pytest benchmark/
71-
```
57+
1. Setup environment variable `CUDA_HOME` with the path to the CUDA Toolkit installation.
58+
2. Run `build_tests` script located in `test/cython` appropriate to your platform. This will both cythonize the tests and build them.
7259

73-
## Examples
60+
To run these tests:
61+
* `python -m pytest tests/cython/` against local builds
62+
* `pytest tests/cython/` against installed packages
63+
64+
### Samples
7465

75-
CUDA Samples rewriten using CUDA Python are found in `examples`.
66+
Various [CUDA Samples](https://github.com/NVIDIA/cuda-samples/tree/master) that were rewritten using CUDA Python are located in `examples`.
7667

77-
Custom extra included examples:
68+
In addition, extra examples are included:
7869

79-
- `examples/extra/jit_program_test.py`: Demonstrates the use of the API to compile and
70+
* `examples/extra/jit_program_test.py`: Demonstrates the use of the API to compile and
8071
launch a kernel on the device. Includes device memory allocation /
8172
deallocation, transfers between host and device, creation and usage of
8273
streams, and context management.
83-
- `examples/extra/numba_emm_plugin.py`: Implements a Numba External Memory Management
74+
* `examples/extra/numba_emm_plugin.py`: Implements a Numba External Memory Management
8475
plugin, showing that this CUDA Python Driver API can coexist with other
8576
wrappers of the driver API.
77+
78+
To run these samples:
79+
* `python -m pytest tests/cython/` against local builds
80+
* `pytest tests/cython/` against installed packages
81+
82+
### Benchmark (WIP)
83+
84+
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.
85+
86+
The intended way to run these benchmarks was:
87+
* `python -m pytest --benchmark-only benchmark/` against local builds
88+
* `pytest --benchmark-only benchmark/` against installed packages
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cmd /V /C "set CL=%CL% /I%CUDA_HOME%\\include && cythonize -3 -i test_*.pyx"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
cd "$(dirname "$0")"
4+
CPLUS_INCLUDE_PATH=$CUDA_HOME/include:$CPLUS_INCLUDE_PATH cythonize -3 -i test_*.pyx

cuda_bindings/tests_cython/test_ccuda.pyx renamed to cuda_bindings/tests/cython/test_ccuda.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# this software. Any use, reproduction, disclosure, or distribution of
66
# this software and related documentation outside the terms of the EULA
77
# is strictly prohibited.
8+
9+
# distutils: language=c++
810
from libc.string cimport (
911
memset,
1012
memcmp

cuda_bindings/tests_cython/test_ccudart.pyx renamed to cuda_bindings/tests/cython/test_ccudart.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# this software. Any use, reproduction, disclosure, or distribution of
66
# this software and related documentation outside the terms of the EULA
77
# is strictly prohibited.
8+
9+
# distutils: language=c++
810
from libc.string cimport (
911
memset,
1012
memcmp

cuda_bindings/tests_cython/test_interoperability_cython.pyx renamed to cuda_bindings/tests/cython/test_interoperability_cython.pyx

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

9-
# TODO: update to new module once the old ones are removed, we use the
10-
# tests to cover backward compatibility.
11-
import pytest
9+
# distutils: language=c++
10+
from libc.stdlib cimport calloc, free
1211
import cuda.cuda as cuda
1312
import cuda.cudart as cudart
1413
import numpy as np
14+
import pytest
1515

16+
# TODO: update to new module once the old ones are removed, we use the
17+
# tests to cover backward compatibility.
1618
cimport cuda.ccuda as ccuda
1719
cimport cuda.ccudart as ccudart
18-
from libc.stdlib cimport calloc, free
1920

2021

2122
def supportsMemoryPool():

cuda_bindings/tests/pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
norecursedirs = cython

0 commit comments

Comments
 (0)