Artelnics/opennn
OpenNN - Open Neural Networks Library
What is OpenNN?
OpenNN is a modern C++ library (written for the C++20 standard) that lets developers build, train, and run neural‑network models directly from C++ code. It supports the usual data types – tabular tables, images, time‑series, and plain text – and can run on a regular CPU or, optionally, on an NVIDIA GPU via CUDA.
Who might use it?
| Audience | Why it matters |
|---|---|
| C++ engineers who need a neural‑network component inside a larger C++ application (e.g., robotics, finance, embedded systems). | No need to switch languages or embed a Python interpreter; the library compiles straight into the binary. |
| Performance‑focused teams that want fine‑grained control over CPU vs. GPU execution, threading (OpenMP, oneTBB) and low‑level optimisations. | You can pick the backend that matches your hardware and compile‑time constraints. |
| Researchers or hobbyists who prefer a self‑contained, open‑source stack without heavyweight Python dependencies. | The library ships with examples, benchmarks against PyTorch, and a quick‑start guide. |
| Companies that need a commercial‑friendly licence for closed‑source products. | Dual‑licensing (AGPL + commercial) lets you stay compliant while keeping proprietary code private. |
How does it work?
- Installation – Clone the repo, run CMake, and choose either a CPU‑only or a CUDA‑enabled build. The build pulls in Eigen and zlib automatically; other optional runtimes (MKL, oneDNN, etc.) must be supplied by the user.
- Programming model – Include the public headers (e.g.,
opennn/network/network.h) and use theOpenNN::namespace to create layers, loss functions, optimisers, etc. The library follows a modular layout (core, data, network, backends). - Training & inference – Feed data (CSV, image folders, etc.) into a
DataSetobject, configure aNeuralNetwork, calltrain(), thenpredict()for inference. The same model can be exported as plain C or Python source code for deployment on platforms where the full library isn’t needed. - Benchmarks & validation – The
benchmarks/folder contains scripts that compare OpenNN’s speed and accuracy to PyTorch, following a documented measurement protocol. - Testing & CI – Unit tests live in
tests/, and GitHub Actions run the test suite on every push.
When would you choose OpenNN over other tools?
| Situation | OpenNN advantage |
|---|---|
| C++‑only codebase – you don’t want a Python runtime. | Pure C++ API, can be compiled into a static or shared library. |
| Embedded or real‑time systems – strict binary size or latency constraints. | Exportable C code and fine‑tuned compile options; optional CUDA for GPU acceleration. |
| Need for dual licensing – you want an AGPL base but a commercial path for proprietary products. | Explicit dual‑license model with a commercial option from Artelnics. |
| Performance comparison – you want to see how a C++ implementation stacks up against PyTorch. | Built‑in benchmark suite with reproducible protocols. |
If you already rely heavily on Python ecosystems (PyTorch, TensorFlow) and don’t need C++ integration, those tools may be simpler. OpenNN shines when C++ integration, licensing flexibility, or low‑level performance control are primary concerns.
Getting started (quick recap)
# Clone & configure a CPU‑only build
git clone https://github.com/Artelnics/opennn.git
cd opennn
cmake -S . -B ../opennn-build -DCMAKE_BUILD_TYPE=Release \
-DOpenNN_DISABLE_CUDA=ON -DOpenNN_BUILD_EXAMPLES=ON
cmake --build ../opennn-build --target blank --parallel
# Run the minimal example
../opennn-build/bin/blank
From there, follow the Iris example in examples/ to train a classifier, evaluate it, and export the model.
TL;DR
OpenNN is a C++20 neural‑network library that can run on CPU or CUDA GPUs, supports common data types, offers export to plain C/Python, includes benchmarks against PyTorch, and provides a dual AGPL/commercial licence. It’s a solid choice for developers who need a native C++ ML component or want fine‑grained control over deployment and licensing.
Related
- Project
- Project
- Project
- Project
- Project