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.
What opens 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.
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
Open a .onnx file step by step
- Confirm the file really is a .onnx. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
- On Windows, open it with Netron (graph viewer) or Python (onnx, onnxruntime).
- On Mac, use Netron (graph viewer) or Python (onnx, onnxruntime).
- On Linux, try Netron or Python (onnx, onnxruntime).
- Still stuck? Convert the .onnx to Various framework formats, which opens more widely.
Why can't I open my .onnx file?
Almost always because no installed app understands ONNX. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.
The other possibility is that the file is not really a .onnx at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.
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 has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.
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. How sources are ranked and what is deliberately left out is set out in the methodology.