Install ONNX Runtime for ROCm#
ONNX Runtime accelerates machine learning inference using the AMD MIGraphX execution provider on ROCm-supported GPUs.
Prerequisites#
ONNX Runtime is currently supported on:
gfx950AMD Instinct MI355X and MI350Xgfx942AMD Instinct MI325X and MI300Xgfx1200,gfx1201,gfx1100,gfx1101, andgfx1102Radeon GPUs.
See the ROCm compatibility matrix for more information.
Ensure your system has Python 3.14 or 3.12 installed and accessible.
ONNX Runtime is currently supported on gfx950 AMD Instinct MI355X and MI350X
data center GPUs and gfx942 MI325X and MI300X GPUs. See the ROCm
compatibility matrix (ROCm 7.14.1)
for more information.
Ensure your system has Python 3.12 installed and accessible.
ONNX Runtime is currently supported on gfx950 AMD Instinct MI355X and MI350X
data center GPUs and gfx942 MI325X and MI300X GPUs. See the ROCm
compatibility matrix (ROCm 7.14.0)
for more information.
Ensure your system has Python 3.12 installed and accessible.
Install the ROCm Core SDK#
For instructions, see Install AMD ROCm. Use the selector panel on that page to view instructions appropriate for your system environment.
For instructions, see Install AMD ROCm 7.14.1. Use the selector panel on that page to view instructions appropriate for your system environment.
For instructions, see Install AMD ROCm 7.14.0. Use the selector panel on that page to view instructions appropriate for your system environment.
Install ONNX Runtime using pip#
Create and activate a virtual environment or activate an existing ROCm 10.0.0 environment.
python3.14 -m venv .venv source .venv/bin/activate
python3.12 -m venv .venv source .venv/bin/activate
Install MIGraphX using pip. See Install MIGraphX for installation instructions.
Install ONNX Runtime and the
onnxruntime-ep-migraphxexecution provider plugin.python -m pip install --extra-index-url https://stable.repo.amd.com/rocm/onnxruntime/whl-next/ "onnxruntime-ep-migraphx==1.0.0+rocm10.0.0"
As a workaround due to packaging issues, create the required soname symlink and set library search paths. For example, if you installed MIGraphX using pip:
SP=$(python -c "import site; print(site.getsitepackages()[0])") ln -sf $SP/onnxruntime/capi/libonnxruntime.so.1.29.0 $SP/onnxruntime/capi/libonnxruntime.so.1 export LD_LIBRARY_PATH=$SP/onnxruntime/capi:$SP/migraphx_libs:$LD_LIBRARY_PATH
Tip
The symlink only needs to be created once. For persistence,
LD_LIBRARY_PATHshould be set for each shell session or added to your shell startup script (e.g.~/.bashrc).Confirm ONNX Runtime is correctly installed and the MIGraphX execution provider is available.
The EP plugin must be explicitly registered using
onnxruntime_ep_migraphxbefore querying available providers.migraphxmust be imported first to initialize the ROCm runtime.python -c "import migraphx, onnxruntime as ort, onnxruntime_ep_migraphx as m; [ort.register_execution_provider_library(n,p) for n,p in zip(m.get_ep_names(), m.get_library_paths())]; print(ort.get_available_providers())"
You should see
MIGraphXExecutionProviderin the output:['CPUExecutionProvider', 'MIGraphXExecutionProvider']
Create and activate a virtual environment or activate an existing ROCm 7.14.1 environment. To create a new Python 3.12 virtual environment:
python3.12 -m venv .venv source .venv/bin/activate
Download and install the wheels.
python -m pip install https://rocm.frameworks.amd.com/whl-multi-arch/onnxruntime-migraphx/onnxruntime_migraphx-1.23.2%2Brocm7.14.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Verify your installation#
Download and extract the test binary zip file.
wget https://rocm.frameworks.amd.com/whl-multi-arch/onnxruntime-migraphx/onnxruntime_migraphx-1.23.2%2Brocm7.14.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.zip unzip onnxruntime_migraphx-1.23.2+rocm7.14.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.zip cd build/Linux/Release
Run the test suite.
./onnxruntime_test_all \ --gtest_filter=-:CudaKernelTest.SoftmaxGrad_LargeTensor_LastAxis_Float16:CudaKernelTest.SoftmaxGrad_LargeTensor_LastAxis_Float16_NoPowerOfTwo:CudaKernelTest.SoftmaxGrad_LargeTensor_AllAxis_Float16:CudaKernelTest.SoftmaxGrad_LargeTensor_AllAxis_Float16_NoPowerOfTwo:CudaKernelTest.LogSoftmaxGrad_LargeTensor_LastAxis_Float16:CudaKernelTest.LogSoftmaxGrad_LargeTensor_LastAxis_Float16_NoPowerOfTwo:CudaKernelTest.LogSoftmaxGrad_LargeTensor_AllAxis_Float16:CudaKernelTest.LogSoftmaxGrad_LargeTensor_AllAxis_Float16_NoPowerOfTwo:ReductionOpTest.ReductionVariationTest:GatherOpTest.Gather_invalid_index_cpu:Scatter.InvalidIndex:GradientCheckerTest.AddGrad:GradientCheckerTest.SubGrad:GradientCheckerTest.MulGrad:GradientCheckerTest.DivGrad:NhwcTransformerTests*:QDQTransformerTests*Sample Output for Unit Test
Create and activate a virtual environment or activate an existing ROCm 7.14.0 environment. To create a new Python 3.12 virtual environment:
python3.12 -m venv .venv source .venv/bin/activate
Download and install the wheels.
python -m pip install https://rocm.frameworks.amd.com/whl-multi-arch/onnxruntime-migraphx/onnxruntime_migraphx-1.23.2%2Brocm7.14.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Verify your installation#
Download and extract the test binary zip file.
wget https://rocm.frameworks.amd.com/whl-multi-arch/onnxruntime-migraphx/onnxruntime_migraphx-1.23.2%2Brocm7.14.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.zip unzip onnxruntime_migraphx-1.23.2+rocm7.14.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.zip cd build/Linux/Release
Run the test suite.
./onnxruntime_test_all \ --gtest_filter=-:CudaKernelTest.SoftmaxGrad_LargeTensor_LastAxis_Float16:CudaKernelTest.SoftmaxGrad_LargeTensor_LastAxis_Float16_NoPowerOfTwo:CudaKernelTest.SoftmaxGrad_LargeTensor_AllAxis_Float16:CudaKernelTest.SoftmaxGrad_LargeTensor_AllAxis_Float16_NoPowerOfTwo:CudaKernelTest.LogSoftmaxGrad_LargeTensor_LastAxis_Float16:CudaKernelTest.LogSoftmaxGrad_LargeTensor_LastAxis_Float16_NoPowerOfTwo:CudaKernelTest.LogSoftmaxGrad_LargeTensor_AllAxis_Float16:CudaKernelTest.LogSoftmaxGrad_LargeTensor_AllAxis_Float16_NoPowerOfTwo:ReductionOpTest.ReductionVariationTest:GatherOpTest.Gather_invalid_index_cpu:Scatter.InvalidIndex:GradientCheckerTest.AddGrad:GradientCheckerTest.SubGrad:GradientCheckerTest.MulGrad:GradientCheckerTest.DivGrad:NhwcTransformerTests*:QDQTransformerTests*Sample Output for Unit Test
See also
See MIGraphX Execution Provider (ONNX Runtime docs) for more information.