The setuptools-cpp-cuda is a module that extends setuptools functionality for building hybrid C++ and CUDA extensions
Project description
Setuptools C++ CUDA
The setuptools-cpp-cuda is a module that extends setuptools functionality for building hybrid C++ and CUDA extensions for Python wrapper modules.
Table of Contents
Summary
This project meant to be a soft solution to include mixed c++/CUDA extensions in your projects, no matter if you are using old python version (3.6+) or old GPU drivers (sm/compute arch 3.0+).
Features
- Python version >= 3.6 .
- SM(StreamingMultiprocessor)/Compute architecture >= 3.0 .
- Cython compatible but not mandatory.
- Any CUDA version (since you can configure nvcc flags).
- Preloaded flags for cpp and CUDA compilers.
- Mixed compilations (.cpp and .cu files can be included in a single extension).
- Advanced find_cuda features (automatically try to find the CUDAHOME directory).
- Include NVIDIA Management Library (NVML) capabilities info.
Installation
pip install setuptools-cpp-cuda
Usage
Add the library to your project configuration files ("pyproject.toml", "setup.py/.cfg" or "requirements.txt"):
# [pyproject.toml]
[build-system]
requires = ["setuptools-cpp-cuda"]
# ...
# [requirements.txt]
setuptools-cpp-cuda
And configure the setup.py for the different extensions you want to use:
# [setup.py]
from setuptools import setup
from setuptools_cpp_cuda import CudaExtension, BuildExtension, fix_dll
cuda_ext = CudaExtension(
name='cudaext',
include_dirs=['include'],
sources=['cudaext.cu', 'cudaext_wrapper.cpp'],
libraries=fix_dll(['cudart']), # Use fix_dll() only for Windows compatibility (check documentation for more info).
extra_compile_args={
'cxx': ['-g'], # cpp compiler flags
'nvcc': ['-O2'], # nvcc flags
},
)
setup(
ext_modules=[cuda_ext],
cmdclass={'build_ext': BuildExtension},
)
Issues
If you receive a EnvironmentError exception you should set CUDAHOME environment variable pointing to the CUDA installation path. This would happen if the find_cuda() method is not capable of locate it. As reference the directory should contain:
CUDAHOME
├── bin
│ └── nvcc
├── include
│ └── cudart.h
├── lib
└── nvml
License
setuptools-cpp-cuda
is distributed under the terms of the MIT license.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for setuptools-cpp-cuda-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 123c9dc00005f0af95b145866e76d7c8c894d45ee304fd77bf668150bc59fef7 |
|
MD5 | 30d8cfda1418ade274a9b1cd4dcb66e2 |
|
BLAKE2b-256 | 0013d8c82c940407669bf42f053c889617931793b5d3414c472bc3092d017ff6 |
Hashes for setuptools_cpp_cuda-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44f0f335079d9bcfcba007cef41f7731032aa2f3541e7ffc5342000ba2aae8c7 |
|
MD5 | e05e31ebde56f64a355dae78cdcac349 |
|
BLAKE2b-256 | 0d1b6cfd114fb1ae1e1dba9a799ccfb419a8055adb4ba9c534e84885e16e3b5e |