Skip to content

Commit 9cdcf70

Browse files
Copilotumireon
andauthored
Add MIGraphX execution provider support (#740)
Introduces support for the ONNX Runtime MIGraphX execution provider, including build detection, UI options, localization, and session creation logic. Updates documentation to reflect MIGraphX as the recommended AMD GPU backend, noting ROCM deprecation in ONNX Runtime 1.23.0. Co-authored-by: Kaito Udagawa <[email protected]>
1 parent 41b6d39 commit 9cdcf70

File tree

7 files changed

+25
-1
lines changed

7 files changed

+25
-1
lines changed

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,17 @@ if(HAVE_ONNXRUNTIME_ROCM_EP)
177177
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE HAVE_ONNXRUNTIME_ROCM_EP)
178178
endif()
179179

180+
check_library_exists(
181+
onnxruntime::onnxruntime
182+
OrtSessionOptionsAppendExecutionProvider_MIGraphX
183+
onnxruntime_c_api.h
184+
HAVE_ONNXRUNTIME_MIGRAPHX_EP
185+
)
186+
if(HAVE_ONNXRUNTIME_MIGRAPHX_EP)
187+
message(STATUS "ONNX Runtime MIGraphX Execution Provider found")
188+
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE HAVE_ONNXRUNTIME_MIGRAPHX_EP)
189+
endif()
190+
180191
check_library_exists(
181192
onnxruntime::onnxruntime
182193
OrtSessionOptionsAppendExecutionProvider_Tensorrt

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ GPU support:
6363

6464
- On Windows, we plan to support WinML acceleration.
6565
- On Mac we support CoreML for acceleration, which is efficient on Apple Silicon. **Note:** This plugin does not support cross-architecture translation (Rosetta2). Intel binaries on Apple Silicon or Apple Silicon binaries on Intel will crash.
66-
- On Linux CUDA and ROCM are supported if this plugin is built from source. Ensure your ONNX Runtime installation has CUDA or ROCM support.
66+
- On Linux CUDA, ROCM (deprecated in ONNX Runtime 1.23.0), and MIGraphX are supported if this plugin is built from source. Ensure your ONNX Runtime installation has CUDA, ROCM, or MIGraphX support. For AMD GPUs, MIGraphX is recommended as ROCM was removed from ONNX Runtime starting with version 1.23.0.
6767
- The goal of this plugin is to be available for everyone on every system, even if they don't own a GPU.
6868

6969
Number of CPU threads is controllable through the UI settings. A 2-thread setting works best.

data/locale/en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ InferenceDevice="Inference device"
99
CPU="CPU"
1010
GPUCUDA="GPU - CUDA"
1111
GPUROCM="GPU - ROCM"
12+
GPUMIGRAPHX="GPU - MIGraphX"
1213
TENSORRT="TensorRT"
1314
CoreML="CoreML"
1415
SegmentationModel="Segmentation model"

src/background-filter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ obs_properties_t *background_filter_properties(void *data)
170170
#ifdef HAVE_ONNXRUNTIME_ROCM_EP
171171
obs_property_list_add_string(p_use_gpu, obs_module_text("GPUROCM"), USEGPU_ROCM);
172172
#endif
173+
#ifdef HAVE_ONNXRUNTIME_MIGRAPHX_EP
174+
obs_property_list_add_string(p_use_gpu, obs_module_text("GPUMIGRAPHX"), USEGPU_MIGRAPHX);
175+
#endif
173176
#ifdef HAVE_ONNXRUNTIME_TENSORRT_EP
174177
obs_property_list_add_string(p_use_gpu, obs_module_text("TENSORRT"), USEGPU_TENSORRT);
175178
#endif

src/consts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const char *const MODEL_RMBG = "models/bria_rmbg_1_4_qint8.onnx";
1717
const char *const USEGPU_CPU = "cpu";
1818
const char *const USEGPU_CUDA = "cuda";
1919
const char *const USEGPU_ROCM = "rocm";
20+
const char *const USEGPU_MIGRAPHX = "migraphx";
2021
const char *const USEGPU_TENSORRT = "tensorrt";
2122
const char *const USEGPU_COREML = "coreml";
2223

src/enhance-filter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ obs_properties_t *enhance_filter_properties(void *data)
6363
#ifdef HAVE_ONNXRUNTIME_ROCM_EP
6464
obs_property_list_add_string(p_use_gpu, obs_module_text("GPUROCM"), USEGPU_ROCM);
6565
#endif
66+
#ifdef HAVE_ONNXRUNTIME_MIGRAPHX_EP
67+
obs_property_list_add_string(p_use_gpu, obs_module_text("GPUMIGRAPHX"), USEGPU_MIGRAPHX);
68+
#endif
6669
#ifdef HAVE_ONNXRUNTIME_TENSORRT_EP
6770
obs_property_list_add_string(p_use_gpu, obs_module_text("TENSORRT"), USEGPU_TENSORRT);
6871
#endif

src/ort-utils/ort-session-utils.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ int createOrtSession(filter_data *tf)
6565
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_ROCM(sessionOptions, 0));
6666
}
6767
#endif
68+
#ifdef HAVE_ONNXRUNTIME_MIGRAPHX_EP
69+
if (tf->useGPU == USEGPU_MIGRAPHX) {
70+
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_MIGraphX(sessionOptions, 0));
71+
}
72+
#endif
6873
#ifdef HAVE_ONNXRUNTIME_TENSORRT_EP
6974
if (tf->useGPU == USEGPU_TENSORRT) {
7075
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_Tensorrt(sessionOptions, 0));

0 commit comments

Comments
 (0)