Practical overview
When it fits
Use Tract when an application needs to run supported neural-network models locally and you want an inference library rather than a hosted serving endpoint.
Who it is for
- Rust developers integrating model inference into applications.
- Teams building local or embedded inference workflows.
- Developers exploring Python access to the same inference pipeline.
Documented uses
- Load and run ONNX or NNEF models from a Rust application.
- Run supported legacy TensorFlow Lite or TensorFlow 1 frozen-graph models.
- Prepare models for CPU, Apple Metal, NVIDIA CUDA or WebAssembly runtimes.
- Convert models to NNEF at build time and package a smaller runtime.
- Build streaming inference workflows using pulsification.
Requirements & limits
- The README specifies Rust 1.91.0 or newer for the Rust workflow.
- Use the public tract crate; the README says internal crates are not stable public interfaces.
- Model format and operator requirements affect deployment: ONNX-only operators may require tract-onnx-opl, and pulsified models may require tract-pulse-opl.
- The documented runtime options include CPU, Apple Metal, NVIDIA CUDA and WebAssembly; select based on the intended target.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Run an ONNX model with tract in a Rust application
Load, prepare, and run an ONNX model using tract’s default runtime.
Before you start
- Rust compiler version 1.91.0 or later.
- The public
tractcrate and an ONNX model file. - An input value convertible with tract’s ndarray interoperability.
Steps
Import
tract::prelude::*and enable interoperability withtract::impl_ndarray_interop!().Load the ONNX model with
tract::onnx()?.load("mobilenetv2-7.onnx")?.into_model()?.Select the default runtime using
tract::runtime_for_name("default")?and prepare the model withruntime.prepare(model)?.Run the prepared model with
runnable.run([input.tract()?])?.
Expected outcome
The model’s inference result is returned by `run`.
Guide limitations
- The example assumes an ONNX model and input value are available; input construction and preprocessing are not specified.
- The README identifies
tractas the authoritative public API and cautions against depending directly on internal crates. - The example does not document error handling beyond propagating errors with
?.
Convert a model to NNEF and prepare a compact tract runtime
Use the documented build-time conversion and runtime composition workflow for an NNEF model.
Before you start
- A model in ONNX, TensorFlow, or TensorFlow Lite format.
- The
tractCLI for conversion. - A runtime build that includes
tract-coreandtract-nnef.
Steps
At build time, convert the source model to NNEF with
tract model.onnx dump --nnef model.nnef.tgz, substituting the appropriate source model path and format.At runtime, include
tract-coreandtract-nnef.If the model uses ONNX-only operators, also include
tract-onnx-opl; if it is pulsified, also includetract-pulse-opl.
Expected outcome
The workflow separates model conversion from runtime loading and uses the documented NNEF-based runtime components.
Guide limitations
- The CLI example uses an ONNX input; commands for TensorFlow or TensorFlow Lite conversion are not shown.
- The README does not provide build-system instructions or a runtime execution example for the converted archive.
- tract-OPL extensions are described as more in flux than NNEF parts; the stated compatibility rule is for serialized tract
0.x.ymodels with tract0.x.zwherez >= y.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 16 October 2026
- Original website title
- sonos/tract · Official homepage title · retained in its source language

