A small C++/CUDA framework for training and querying neural networks, with fast fused MLPs, multiresolution hash encodings, and optional PyTorch bindings.
Overview
tiny-cuda-nn is a self-contained C++/CUDA library for neural network training and inference. It centers on a fully fused multi-layer perceptron implementation, a multiresolution hash encoding, and pluggable input encodings, loss functions, and optimizers configured through JSON.
Optional JIT fusion compiles models into CUDA device functions for extra speed on supported hardware, with automatic fallback if compilation fails. Applications can fuse a tiny-cuda-nn model into larger custom CUDA kernels through the runtime compilation API, as used in neural graphics workloads referenced in the documentation.
The project targets NVIDIA GPUs with CUDA and benefits from tensor cores when available. A PyTorch extension exposes fast MLPs and encodings from Python, though small batch sizes can add overhead compared with native CUDA. Sample code learns image functions and demonstrates integration patterns.
Encodings include grid, spherical harmonics, identity, and related variants; losses cover L1, L2, cross entropy, and several relative error forms; optimizers include SGD plus wrappers for averaging, batching, composites, EMA, and exponential decay schedules.
Key features
- Fully fused MLP implementation
- Multiresolution hash grid encoding
- Multiple losses and optimizers
- Optional automatic JIT fusion
- C++/CUDA training and inference API
- PyTorch extension bindings
- JSON-driven model configuration
- Runtime compilation for fused kernels
Use cases
- Fast MLP training on NVIDIA GPUs
- Neural field and NeRF-style research
- Image-function regression samples
- PyTorch-accelerated encodings
- Custom CUDA kernels with embedded models