Skip to content

Commit ba85eda

Browse files
authored
Merge pull request #269234 from msakande/freshness-onnx-concept
freshness review for concept-ONNX
2 parents ba7144f + 4001b71 commit ba85eda

File tree

2 files changed

+45
-37
lines changed

2 files changed

+45
-37
lines changed

articles/machine-learning/concept-onnx.md

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,90 +5,98 @@ description: Learn how using the Open Neural Network Exchange (ONNX) can help op
55
services: machine-learning
66
ms.service: machine-learning
77
ms.subservice: core
8-
ms.topic: conceptual
8+
ms.topic: concept-article
99
ms.author: kritifaujdar
1010
author: fkriti
1111
ms.reviewer: mopeakande
12-
ms.date: 11/04/2022
12+
ms.date: 03/18/2024
13+
14+
#customer intent: As a data scientist, I want learn how to use ONNX to create machine learning models and accelerate inferencing.
1315
---
1416

15-
# ONNX and Azure Machine Learning: Create and accelerate ML models
17+
# ONNX and Azure Machine Learning
18+
19+
Learn how use of the [Open Neural Network Exchange](https://onnx.ai) (ONNX) can help to optimize the inference of your machine learning model. _Inference_ or _model scoring_, is the process of using a deployed model to generate predictions on production data.
1620

17-
Learn how using the [Open Neural Network Exchange](https://onnx.ai) (ONNX) can help optimize the inference of your machine learning model. Inference, or model scoring, is the phase where the deployed model is used for prediction, most commonly on production data.
21+
Optimizing machine learning models for inference requires you to tune the model and the inference library to make the most of the hardware capabilities. This task becomes complex if you want to get optimal performance on different kinds of platforms such as cloud or edge, CPU or GPU, and so on, since each platform has different capabilities and characteristics. The complexity increases if you have models from various frameworks that need to run on different platforms. It can be time-consuming to optimize all the different combinations of frameworks and hardware. Therefore, a useful solution is to train your model once in your preferred framework and then run it anywhere on the cloud or edge—this solution is where ONNX comes in.
1822

19-
Optimizing machine learning models for inference (or model scoring) is difficult since you need to tune the model and the inference library to make the most of the hardware capabilities. The problem becomes extremely hard if you want to get optimal performance on different kinds of platforms (cloud/edge, CPU/GPU, etc.), since each one has different capabilities and characteristics. The complexity increases if you have models from a variety of frameworks that need to run on a variety of platforms. It's very time consuming to optimize all the different combinations of frameworks and hardware. A solution to train once in your preferred framework and run anywhere on the cloud or edge is needed. This is where ONNX comes in.
23+
## What is ONNX?
2024

21-
Microsoft and a community of partners created ONNX as an open standard for representing machine learning models. Models from [many frameworks](https://onnx.ai/supported-tools) including TensorFlow, PyTorch, SciKit-Learn, Keras, Chainer, MXNet, MATLAB, and SparkML can be exported or converted to the standard ONNX format. Once the models are in the ONNX format, they can be run on a variety of platforms and devices.
25+
Microsoft and a community of partners created ONNX as an open standard for representing machine learning models. Models from [many frameworks](https://onnx.ai/supported-tools) including TensorFlow, PyTorch, scikit-learn, Keras, Chainer, MXNet, and MATLAB can be exported or converted to the standard ONNX format. Once the models are in the ONNX format, they can be run on various platforms and devices.
2226

23-
[ONNX Runtime](https://onnxruntime.ai) is a high-performance inference engine for deploying ONNX models to production. It's optimized for both cloud and edge and works on Linux, Windows, and Mac. Written in C++, it also has C, Python, C#, Java, and JavaScript (Node.js) APIs for usage in a variety of environments. ONNX Runtime supports both DNN and traditional ML models and integrates with accelerators on different hardware such as TensorRT on NVidia GPUs, OpenVINO on Intel processors, DirectML on Windows, and more. By using ONNX Runtime, you can benefit from the extensive production-grade optimizations, testing, and ongoing improvements.
27+
[ONNX Runtime](https://onnxruntime.ai) is a high-performance inference engine for deploying ONNX models to production. It's optimized for both cloud and edge and works on Linux, Windows, and Mac. While ONNX is written in C++, it also has C, Python, C#, Java, and JavaScript (Node.js) APIs for usage in many environments. ONNX Runtime supports both deep neural networks (DNN) and traditional machine learning models, and it integrates with accelerators on different hardware such as TensorRT on Nvidia GPUs, OpenVINO on Intel processors, and DirectML on Windows. By using ONNX Runtime, you can benefit from the extensive production-grade optimizations, testing, and ongoing improvements.
2428

25-
ONNX Runtime is used in high-scale Microsoft services such as Bing, Office, and Azure AI. Performance gains are dependent on a number of factors, but these Microsoft services have seen an __average 2x performance gain on CPU__. In addition to Azure Machine Learning services, ONNX Runtime also runs in other products that support Machine Learning workloads, including:
26-
+ Windows: The runtime is built into Windows as part of [Windows Machine Learning](/windows/ai/windows-ml/) and runs on hundreds of millions of devices.
27-
+ Azure SQL product family: Run native scoring on data in [Azure SQL Edge](../azure-sql-edge/onnx-overview.md) and [Azure SQL Managed Instance](/azure/azure-sql/managed-instance/machine-learning-services-overview).
28-
+ ML.NET: [Run ONNX models in ML.NET](/dotnet/machine-learning/tutorials/object-detection-onnx).
29+
ONNX Runtime is used in high-scale Microsoft services such as Bing, Office, and Azure AI. Although performance gains depend on many factors, these Microsoft services report an __average 2x performance gain on CPU__. In addition to Azure Machine Learning services, ONNX Runtime also runs in other products that support Machine Learning workloads, including:
2930

31+
- __Windows__: The runtime is built into Windows as part of [Windows Machine Learning](/windows/ai/windows-ml/) and runs on hundreds of millions of devices.
32+
- __Azure SQL product family__: Run native scoring on data in [Azure SQL Edge](../azure-sql-edge/onnx-overview.md) and [Azure SQL Managed Instance](/azure/azure-sql/managed-instance/machine-learning-services-overview).
33+
- __ML.NET__: [Run ONNX models in ML.NET](/dotnet/machine-learning/tutorials/object-detection-onnx).
3034

31-
[![ONNX flow diagram showing training, converters, and deployment](./media/concept-onnx/onnx.png)](././media/concept-onnx/onnx.png#lightbox)
35+
:::image type="content" source="media/concept-onnx/onnx.png" alt-text="ONNX flow diagram showing training, converters, and deployment." lightbox="media/concept-onnx/onnx.png":::
3236

33-
## Get ONNX models
37+
## How to obtain ONNX models
3438

3539
You can obtain ONNX models in several ways:
36-
+ Train a new ONNX model in Azure Machine Learning (see examples at the bottom of this article) or by using [automated Machine Learning capabilities](concept-automated-ml.md#automl--onnx)
37-
+ Convert existing model from another format to ONNX (see the [tutorials](https://github.com/onnx/tutorials))
38-
+ Get a pre-trained ONNX model from the [ONNX Model Zoo](https://github.com/onnx/models)
39-
+ Generate a customized ONNX model from [Azure AI Custom Vision service](../ai-services/custom-vision-service/index.yml)
4040

41-
Many models including image classification, object detection, and text processing can be represented as ONNX models. If you run into an issue with a model that cannot be converted successfully, please file an issue in the GitHub of the respective converter that you used. You can continue using your existing format model until the issue is addressed.
41+
- Train a new ONNX model in Azure Machine Learning (as described in the [examples](#examples) section of this article) or by using [automated machine learning capabilities](concept-automated-ml.md#automl--onnx).
42+
- Convert an existing model from another format to ONNX as shown in these [tutorials](https://github.com/onnx/tutorials).
43+
- Get a pretrained ONNX model from the [ONNX Model Zoo](https://github.com/onnx/models).
44+
- Generate a customized ONNX model from [Azure AI Custom Vision service](../ai-services/custom-vision-service/index.yml).
45+
46+
Many models, including image classification, object detection, and text processing models can be represented as ONNX models. If you run into an issue with a model that can't be converted successfully, file a GitHub issue in the repository of the converter that you used. You can continue using your existing model format until the issue is addressed.
47+
48+
## ONNX model deployment in Azure
4249

43-
## Deploy ONNX models in Azure
50+
With Azure Machine Learning, you can deploy, manage, and monitor your ONNX models. Using the standard [MLOps deployment workflow](concept-model-management-and-deployment.md) and ONNX Runtime, you can create a REST endpoint hosted in the cloud. For hands-on examples, see these [Jupyter notebooks](#examples).
4451

45-
With Azure Machine Learning, you can deploy, manage, and monitor your ONNX models. Using the standard [deployment workflow](concept-model-management-and-deployment.md) and ONNX Runtime, you can create a REST endpoint hosted in the cloud. See example Jupyter notebooks at the end of this article to try it out for yourself.
52+
### Installation and use of ONNX Runtime with Python
4653

47-
### Install and use ONNX Runtime with Python
54+
Python packages for ONNX Runtime are available on [PyPi.org](https://pypi.org) ([CPU](https://pypi.org/project/onnxruntime) and [GPU](https://pypi.org/project/onnxruntime-gpu)). Be sure to review the [system requirements](https://github.com/Microsoft/onnxruntime#system-requirements) before installation.
4855

49-
Python packages for ONNX Runtime are available on [PyPi.org](https://pypi.org) ([CPU](https://pypi.org/project/onnxruntime), [GPU](https://pypi.org/project/onnxruntime-gpu)). Please read [system requirements](https://github.com/Microsoft/onnxruntime#system-requirements) before installation.
56+
To install ONNX Runtime for Python, use one of the following commands:
5057

51-
To install ONNX Runtime for Python, use one of the following commands:
5258
```python
5359
pip install onnxruntime # CPU build
5460
pip install onnxruntime-gpu # GPU build
5561
```
5662

57-
To call ONNX Runtime in your Python script, use:
63+
To call ONNX Runtime in your Python script, use:
64+
5865
```python
5966
import onnxruntime
6067
session = onnxruntime.InferenceSession("path to model")
6168
```
6269

63-
The documentation accompanying the model usually tells you the inputs and outputs for using the model. You can also use a visualization tool such as [Netron](https://github.com/lutzroeder/Netron) to view the model. ONNX Runtime also lets you query the model metadata, inputs, and outputs:
70+
The documentation accompanying the model usually tells you the inputs and outputs for using the model. You can also use a visualization tool such as [Netron](https://github.com/lutzroeder/Netron) to view the model. ONNX Runtime also lets you query the model metadata, inputs, and outputs as follows:
71+
6472
```python
6573
session.get_modelmeta()
6674
first_input_name = session.get_inputs()[0].name
6775
first_output_name = session.get_outputs()[0].name
6876
```
6977

70-
To inference your model, use `run` and pass in the list of outputs you want returned (leave empty if you want all of them) and a map of the input values. The result is a list of the outputs.
78+
To perform inferencing on your model, use `run` and pass in the list of outputs you want returned (or leave the list empty if you want all of them) and a map of the input values. The result is a list of the outputs.
79+
7180
```python
7281
results = session.run(["output1", "output2"], {
7382
"input1": indata1, "input2": indata2})
7483
results = session.run([], {"input1": indata1, "input2": indata2})
7584
```
7685

77-
For the complete Python API reference, see the [ONNX Runtime reference docs](https://onnxruntime.ai/docs/api/python/api_summary.html).
86+
For the complete Python API reference, see the [ONNX Runtime reference docs](https://onnxruntime.ai/docs/api/python/api_summary.html).
7887

7988
## Examples
80-
See [how-to-use-azureml/deployment/onnx](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/onnx) for example Python notebooks that create and deploy ONNX models.
81-
82-
[!INCLUDE [aml-clone-in-azure-notebook](includes/aml-clone-for-examples.md)]
8389

84-
Samples for usage in other languages can be found in the [ONNX Runtime GitHub](https://github.com/microsoft/onnxruntime/tree/master/samples).
90+
- For example Python notebooks that create and deploy ONNX models, see [how-to-use-azureml/deployment/onnx](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/onnx).
91+
- [!INCLUDE [aml-clone-in-azure-notebook](includes/aml-clone-for-examples.md)]
92+
- For samples that show ONNX usage in other languages, see the [ONNX Runtime GitHub](https://github.com/microsoft/onnxruntime/tree/master/samples).
8593

86-
## More info
94+
## Related content
8795

8896
Learn more about **ONNX** or contribute to the project:
89-
+ [ONNX project website](https://onnx.ai)
90-
+ [ONNX code on GitHub](https://github.com/onnx/onnx)
97+
- [ONNX project website](https://onnx.ai)
98+
- [ONNX code on GitHub](https://github.com/onnx/onnx)
9199

92100
Learn more about **ONNX Runtime** or contribute to the project:
93-
+ [ONNX Runtime project website](https://onnxruntime.ai)
94-
+ [ONNX Runtime GitHub Repo](https://github.com/Microsoft/onnxruntime)
101+
- [ONNX Runtime project website](https://onnxruntime.ai)
102+
- [ONNX Runtime GitHub Repo](https://github.com/Microsoft/onnxruntime)

articles/machine-learning/v1/how-to-deploy-inferencing-gpus.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,5 +291,5 @@ aks_target.delete()
291291
## Next steps
292292

293293
* [Deploy model on FPGA](how-to-deploy-fpga-web-service.md)
294-
* [Deploy model with ONNX](../concept-onnx.md#deploy-onnx-models-in-azure)
294+
* [Deploy model with ONNX](../concept-onnx.md#onnx-model-deployment-in-azure)
295295
* [Train TensorFlow DNN Models](../how-to-train-tensorflow.md)

0 commit comments

Comments
 (0)