Build MIGraphX in a Docker container#
2026-10-12
2 min read time
Docker provides a development environment with MIGraphX build prerequisites preinstalled. Use this approach when you want to build MIGraphX from source without installing dependencies on your host system.
The default Dockerfile at the repository root is the image Jenkins CI
builds and uses. That Dockerfile tracks the latest ROCm release through
TheRock (amdrocm-*) packages. Alternative Dockerfiles for other ROCm
releases are available under tools/docker/.
Prerequisites#
Before you build or run a MIGraphX Docker image, install the following on your host:
ROCm with GPU drivers configured
Docker with access to
/dev/kfdand/dev/dri
Build the default Docker image#
From the repository root, build the image:
docker build -t migraphx .
To reduce image size, set GPU_ARCH to the GPU architecture on your
system. Leaving GPU_ARCH unset installs device code for all supported
architectures, which is useful when the same image runs on different
ROCm-supported GPUs.
docker build -t migraphx --build-arg GPU_ARCH=$(rocminfo | grep -o -m1 'gfx.*') .
The root Dockerfile accepts the following build arguments:
Build argument |
Description |
|---|---|
|
ROCm release version for versioned package names. Defaults to the value set in the repository |
|
GPU architecture family (for example, |
|
When set to a non-empty value, installs ROCm from Python wheels instead of system packages. |
|
pip index URL used when |
Run the container#
Start an interactive container with your repository mounted at
/code/AMDMIGraphX:
docker run --device='/dev/kfd' --device='/dev/dri' \
-v=`pwd`:/code/AMDMIGraphX -w /code/AMDMIGraphX \
--group-add video -it migraphx
Build MIGraphX inside the container#
Inside the container, prerequisites are already installed. Follow the steps in MIGraphX on ROCm installation to build from source, starting from the rbuild or CMake build steps.
Alternative Dockerfiles#
Use an alternative Dockerfile when your target ROCm release requires a different base image or package source.
Dockerfile path |
Use when |
|---|---|
|
Building against ROCm 7.2.x and older on Ubuntu 22.04. |
|
Building on Ubuntu 24.04 with ROCm 7.1.1. |
|
Building on Ubuntu 22.04 with ROCm 6.4.2. |
Build with the -f flag to select a Dockerfile. For example:
docker build -t migraphx:legacy -f tools/docker/legacy.dockerfile .
Then follow the same docker run and build steps described above.