Skip to content

Commit

Permalink
Merge pull request #372 from vzhurba01/doc-cython-layer-requirements
Browse files Browse the repository at this point in the history
Document header requirements for Cython users
  • Loading branch information
leofang authored Jan 15, 2025
2 parents 09a1f5d + 083347c commit ee8d7cd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 69 deletions.
16 changes: 8 additions & 8 deletions cuda_bindings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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. 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.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
Expand All @@ -102,13 +102,13 @@ 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)

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
80 changes: 20 additions & 60 deletions cuda_bindings/docs/source/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,91 +2,51 @@

## Runtime Requirements

CUDA Python is supported on all platforms that CUDA is supported. Specific
dependencies are as follows:
`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 Installer.
```{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

```{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 conda-forge cuda-python
```

Conda packages are assigned a dependency to CUDA Toolkit:

* cuda-cudart (Provides CUDA headers to enable writting 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]

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.bindings` 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.
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:

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:

```
export CUDA_HOME=/usr/local/cuda
```console
$ export CUDA_HOME=/usr/local/cuda
```

### In-place

To compile the extension in-place, run:

```{code-block} shell
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

```{code-block} shell
pip install -e .
```console
$ pip install -v -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
```

### 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).
2 changes: 1 addition & 1 deletion cuda_core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ee8d7cd

Please sign in to comment.