What is a .onnx file?
Open Neural Network Exchange · Data · Microsoft, Facebook and partners · 2017
ONNX is an open format for machine-learning models that lets you move a trained model between frameworks. A model built in PyTorch can be exported to ONNX and run in a different runtime or on different hardware.
What is a .onnx file used for?
ONNX stores the model's computation graph and weights using Protocol Buffers, so it has no simple text magic number. Its value is portability: train in one tool, deploy in another, including optimised runtimes on servers, phones and browsers.
You do not open ONNX in a viewer to read it; you run it with ONNX Runtime, or inspect its graph visually in Netron.
How to open a .onnx file
The .onnx format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list. For a step-by-step walkthrough, see how to open a .onnx file.
Windows
- Netron (graph viewer)
- Python (onnx, onnxruntime)
macOS
- Netron (graph viewer)
- Python (onnx, onnxruntime)
Linux
- Netron
- Python (onnx, onnxruntime)
Web
- Netron web app
- ONNX Runtime Web
How to convert a .onnx file
You can convert a .onnx file to Various framework formats using a conversion tool or the export menu of an app that opens it.
.onnx file signature (magic bytes)
Programs recognise a .onnx file by the bytes at the start of the file, not by its name. These are the signatures for ONNX.
| Hex signature | Offset | Note |
|---|---|---|
| (no fixed signature) | 0 | no fixed magic; structure defined by a schema or header |
See the full magic-numbers reference for every format.
Frequently asked questions
What is a .onnx file?
ONNX is an open format for machine-learning models that lets you move a trained model between frameworks. A model built in PyTorch can be exported to ONNX and run in a different runtime or on different hardware.
How do I open an ONNX file?
To see its structure, open it in Netron, a free model viewer. To run it, use ONNX Runtime in Python, C++, JavaScript or C#.
What is ONNX used for?
Moving trained models between frameworks and runtimes. You can train in PyTorch, export to ONNX, and deploy with an optimised runtime on many platforms.
How do I view the layers of an ONNX model?
Open the file in Netron, which draws the computation graph node by node and shows each layer's inputs, outputs and parameters.
Related formats
Sources
Details on this page were checked against authoritative references: