Install ONNX Runtime on ROCm#

ONNX Runtime accelerates machine learning inference using the AMD MIGraphX execution provider on ROCm-supported GPUs. This guide covers building ONNX Runtime from source inside a Docker environment and running unit tests with TheRock-based wheels.

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 for more information.

Prerequisites#

  • Ensure your system has Python 3.12 installed and accessible.

  • wget and unzip available in your shell.

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.

Install ONNX Runtime using pip#

  1. 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
    
  2. 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#

  1. 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
    
  2. 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