RustingBrain
Train anything from an XOR network to a 300M-parameter transformer on one desktop GPU. No Python, no C++ build step — CUDA kernels compile at startup.
let mut model = Network::builder()
.input_size(2)
.dense(8, Activation::Tanh)
.dense(1, Activation::Sigmoid)
.loss(Loss::BinaryCrossEntropy)
.optimizer(Optimizer::adam(0.05))
.build();Read the docs
A deep-learning library in Rust, from a two-layer XOR network up to a 300M-parameter transformer language model trained on one desktop GPU.
StartCUDA SetupRustingBrain builds and trains on CPU by default. CUDA is needed only when you select TrainingBackend::Cuda; that backend is fail-closed and will return an error rather than silently train on CPU.
GuidesImport ModelsRustingBrain runs external models through ONNX. Importing is inference-only: you can load a model trained in TensorFlow, Keras or PyTorch and run predictions from Rust, but training continues to belong in the original framework.
ReferenceTraining throughput baselineMeasured with examples/sweep_arch.rs, one configuration per process, on an otherwise idle RTX 3060 12 GB (desktop applications holding 1258 MiB).
ReferenceChangelogEverything here is additive except the seams around ImagePipeline: ImagePipeline::new takes a PromptEncoder in place of a tokenizer and an encoder and an ImageDenoiser in place of a Dit (a Dit converts into one, so passing one still compiles), the pipeline's tokenizer and encoder fields are now the one encoder field, its denoiser field is an ImageDenoiser, PipelineConfig has gained betas and solver fields, SamplingConfig has gained a solver field, and PromptEncoder::encode hands back the pooled vector alongside the states in place of the separate pool.
Learn by building
- 01
1. Introduction - How a Neural Network Actually Works
This chapter has no code. If you have never understood what a neural network _is_, this is the chapter that fixes that. Everything after this one is practical, and everything after this one assumes you read this one.
- 02
2. Setup — From Nothing to a Running Model
There is no CUDA to install, no Python version to fight, no pip dependency conflicts, no 500 MB of wheels. Two commands and you're training.
- 03
3. The XOR Problem — Your First Trained Network
XOR is the "hello world" of neural networks, and not because it's cute. It is the smallest problem that proves you need a hidden layer. We'll solve it, and then we'll deliberately fail to solve it, because the failure teaches more than the success.
- 04
4. Working With Real Data
Chapter 3 had four hand-typed examples. Real data arrives in files, in the wrong units, with text where you need numbers. This chapter builds the pipeline that every remaining chapter uses: