This repository contains a set of examples on how to achieve Python interoperability with C++ and CUDA, for basic operations, or PyTorch tensor operations.
Example code showcasing how to perform vector addition using Pybind11, a lightweight header-only library that exposes C++ functions to Python.
Example code demonstrating how to perform tensor addition using PyTorch, a popular deep learning framework, and its C++ API for interoperability with Python.
Example code illustrating how to perform vector addition using CUDA (NVIDIA's parallel computing platform) with PyTorch's C++ API for GPU acceleration.
Example code showcasing how to perform vector addition using CUDA with native data structures (without PyTorch).
Example code showcasing how to integrate C++ code in a PyTorch machine learning context. This is taken from Custom C++ and CUDA Extensions from the PyTorch documentation.
Each example directory contains the necessary source files and a setup script (setup.py) for compilation if applicable. Each folder contains a use.py or main.py file that can be used as the main process to run the example.
- Python 3 (Tested on Python 3.10)
- Pybind11 (for Pybind11 examples)
- PyTorch (for PyTorch examples)
- CUDA Toolkit (for CUDA examples)
- C++ compiler (e.g., g++) and development tools
This project is released under the MIT license.