Quick Start
Compile and run a first ONNX model with MIGraphX on an AMD GPU.
This page shows the shortest useful path from an ONNX model to a GPU inference run.
Prerequisites
You need:
- a supported AMD GPU
- ROCm installed
- MIGraphX installed
- an ONNX model with fixed or well-declared input shapes
Check ROCm visibility first:
rocminfo | grep -E 'Name:|Marketing Name' | head -20
rocm-smiIf these commands do not see the GPU, fix ROCm before debugging MIGraphX.
Install MIGraphX
On a ROCm-enabled Linux system, install the package through the ROCm package repository:
sudo apt update
sudo apt install migraphxSome ROCm releases split runtime and development files. For C++ builds, also install the development package if your distro exposes one:
sudo apt install migraphx-devCompile And Run With The Driver
The driver is the fastest way to prove model compatibility:
migraphx-driver compile model.onnx --gpuRun a quick correctness pass with generated inputs:
migraphx-driver run model.onnx --gpuBenchmark it:
migraphx-driver perf model.onnx --gpuFor production, compile once and save the compiled program:
migraphx-driver compile model.onnx --gpu --save model.mxrThen load the saved program later:
migraphx-driver perf model.mxrPython Smoke Test
import migraphx
program = migraphx.parse_onnx("model.onnx")
program.compile(migraphx.get_target("gpu"))
params = {}
for name, shape in program.get_parameter_shapes().items():
params[name] = migraphx.generate_argument(shape)
outputs = program.run(params)
print(outputs)C++ Smoke Test
#include <migraphx/migraphx.hpp>
#include <iostream>
#include <map>
#include <string>
int main()
{
migraphx::program program = migraphx::parse_onnx("model.onnx");
program.compile(migraphx::target{"gpu"});
std::map<std::string, migraphx::argument> inputs;
for(const auto& name : program.get_parameter_names())
{
auto shape = program.get_parameter_shape(name);
inputs[name] = migraphx::generate_argument(shape);
}
auto outputs = program.eval(inputs);
std::cout << "outputs: " << outputs.size() << "\n";
}Production Pattern
Build artifact:
migraphx-driver compile model.onnx --gpu --save model.mxrRuntime process:
load model.mxr
allocate or wrap input buffers
run program
read outputsFor latency-sensitive services, do not parse and compile on every startup request. Compile during a build step or a warm-up step, save the compiled program, and load the saved artifact in production.