Skip to main content

The setuptools-cpp-cuda is a module that extends setuptools functionality for building hybrid C++ and CUDA extensions

Project description

Setuptools C++ CUDA

PyPI - Version PyPI - Python Version

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

setuptools-cpp-cuda-0.1.0.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

setuptools_cpp_cuda-0.1.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file setuptools-cpp-cuda-0.1.0.tar.gz.

File metadata

  • Download URL: setuptools-cpp-cuda-0.1.0.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.27.1

File hashes

Hashes for setuptools-cpp-cuda-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e6d440b1713aac5c675bfc7bc68037e8ff0bae54fd811f49bffbaa0e0295c270
MD5 25a7450d1f48d86cc4d0ad73d78d785c
BLAKE2b-256 a92576b2035af1f74f79c504d1c4761035389c9fe1de246fd0a12f84c3f5f47a

See more details on using hashes here.

File details

Details for the file setuptools_cpp_cuda-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for setuptools_cpp_cuda-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 99817cef1dfb74b66077b7a790bf3fc51f27dfd0eb8f727a2c65a81fe3eed988
MD5 4e5839eb226d280a56b5b12b97eb05b6
BLAKE2b-256 a270d01f305d5cf569a86a2476df24eefd9ba0ea7d8f7c00c213555d0ad71de9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page