2020-10-12 17:28:20 +00:00
---
2022-11-07 18:02:01 +00:00
title: AMD - MIGraphX
2021-11-18 19:00:48 +00:00
description: Instructions to execute ONNX Runtime with the AMD MIGraphX execution provider
2023-01-26 20:18:48 +00:00
parent: Execution Providers
2023-09-20 21:11:50 +00:00
nav_order: 11
2021-11-18 19:00:48 +00:00
redirect_from: /docs/reference/execution-providers/MIGraphX-ExecutionProvider
2020-10-12 17:28:20 +00:00
---
# MIGraphX Execution Provider
{: .no_toc }
2023-01-26 20:18:48 +00:00
The [MIGraphX ](https://github.com/ROCmSoftwarePlatform/AMDMIGraphX/ ) execution provider uses AMD's Deep Learning graph optimization engine to accelerate ONNX model on AMD GPUs.
2020-10-12 17:28:20 +00:00
## Contents
{: .no_toc }
* TOC placeholder
{:toc}
2023-01-26 20:18:48 +00:00
## Install
**NOTE** Please make sure to install the proper version of Pytorch specified here [PyTorch Version ](../install/#training-install-table-for-all-languages ).
For Nightly PyTorch builds please see [Pytorch home ](https://pytorch.org/ ) and select ROCm as the Compute Platform.
Pre-built binaries of ONNX Runtime with MIGraphX EP are published for most language bindings. Please reference [Install ORT ](../install ).
## Requirements
|ONNX Runtime|MIGraphX|
|---|---|
|main|5.4|
2023-03-14 19:01:21 +00:00
|1.14|5.4|
2023-01-26 20:18:48 +00:00
|1.13|5.4|
|1.13|5.3.2|
|1.12|5.2.3|
|1.12|5.2|
2020-10-12 17:28:20 +00:00
## Build
2023-01-26 20:18:48 +00:00
For build instructions, please see the [BUILD page ](../build/eps.md#amd-migraphx ).
2020-10-12 17:28:20 +00:00
2021-05-10 22:19:37 +00:00
## Usage
2020-12-02 00:10:58 +00:00
2020-10-12 17:28:20 +00:00
### C/C++
2020-12-02 00:10:58 +00:00
```c++
Ort::Env env = Ort::Env{ORT_LOGGING_LEVEL_ERROR, "Default"};
2023-01-26 20:18:48 +00:00
Ort::SessionOptions so;
2020-12-02 00:10:58 +00:00
int device_id = 0;
2023-01-26 20:18:48 +00:00
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_MIGraphX(so, device_id));
2020-10-12 17:28:20 +00:00
```
2020-12-02 00:10:58 +00:00
2023-01-26 20:18:48 +00:00
The C API details are [here ](../get-started/with-c.md ).
2020-10-12 17:28:20 +00:00
### Python
2023-01-26 20:18:48 +00:00
2020-10-12 17:28:20 +00:00
When using the Python wheel from the ONNX Runtime build with MIGraphX execution provider, it will be automatically
prioritized over the default GPU or CPU execution providers. There is no need to separately register the execution
2023-01-26 20:18:48 +00:00
provider.
Python APIs details are [here ](https://onnxruntime.ai/docs/api/python/api_summary.html ).
2021-09-17 21:01:15 +00:00
*Note that the next release (ORT 1.10) will require explicitly setting the providers parameter if you want to use execution provider other than the default CPU provider when instantiating InferenceSession.*
2020-10-12 17:28:20 +00:00
You can check [here ](https://github.com/scxiao/ort_test/tree/master/python/run_onnx ) for a python script to run an
model on either the CPU or MIGraphX Execution Provider.
2023-01-26 20:18:48 +00:00
2021-05-10 22:19:37 +00:00
## Configuration Options
MIGraphX providers an environment variable ORT_MIGRAPHX_FP16_ENABLE to enable the FP16 mode.
2023-01-26 20:18:48 +00:00
## Samples
### Python
2020-10-12 17:28:20 +00:00
2023-01-26 20:18:48 +00:00
```python
import onnxruntime as ort
model_path = '< path to model > '
providers = [
'MIGraphXExecutionProvider',
'CPUExecutionProvider',
]
session = ort.InferenceSession(model_path, providers=providers)
```