Install Torch-MIGraphX#

2026-11-27

2 min read time

Applies to Linux

MIGraphX can be integrated with PyTorch workflows by using the Torch-MIGraphX library. It includes the torch.compile API, so you can compile PyTorch models using MIGraphX. This page describes how to install Torch-MIGraphX 1.2 for ROCm 10.2.0 using pip.

Prerequisites#

Torch-MIGraphX 1.2 is supported on the same AMD GPUs as MIGraphX 2.20.0. See the MIGraphX installation page for the list of supported architectures and the ROCm 10.2.0 compatibility matrix for more information.

  • A ROCm-enabled PyTorch build must be installed in the same environment.

Install Torch-MIGraphX on Linux#

Install ROCm#

For instructions, see Install AMD ROCm 10.2.0. Select pip as the installation method and install ROCm 10.2.0 into a Python virtual environment. Use the selector panel on that page to view instructions appropriate for your system environment.

Install Torch-MIGraphX 1.2 using pip#

After installing ROCm, install Torch-MIGraphX. This method installs Torch-MIGraphX into a Python virtual environment.

  1. Activate the ROCm 10.2.0 virtual environment you created while installing ROCm using pip.

    source .venv/bin/activate
    

    Note

    Substitute .venv with the path to your virtual environment if you used a different name or location.

  2. Install a ROCm-enabled PyTorch release into the environment. See Install PyTorch for ROCm, select pip and ROCm 10.2.0 on the selector panel, and install into the same virtual environment. The torch_migraphx wheel in the next step requires a matching ROCm 10.2.0 installation.

  3. Install the torch_migraphx wheel. This also installs the matching MIGraphX 2.20.0 wheels.

    python -c "import torch; print(torch.__version__); assert torch.version.hip, 'ROCm PyTorch required'" && \
    python -m pip install --extra-index-url https://stable.repo.amd.com/rocm/migraphx/whl-next/ \
        "torch_migraphx==1.2+rocm10.2.0"
    
  4. Verify your installation.

    Confirm that the package imports and reports the expected version.

    python -c "import torch_migraphx, importlib.metadata as m; print(m.version('torch_migraphx'))"
    python -c "import torch, torch_migraphx; print('migraphx' in torch._dynamo.list_backends())"
    

    This prints True if the MIGraphX backend is registered as expected.

Uninstall Torch-MIGraphX#

Remove the package from your virtual environment.

python -m pip uninstall torch_migraphx

To also remove the MIGraphX libraries that were installed as dependencies:

python -m pip uninstall migraphx migraphx-libs

Build Torch-MIGraphX from source#

Use the following commands to build torch_migraphx from source:

git clone https://github.com/ROCm/torch_migraphx.git
cd torch_migraphx
pip install . --no-build-isolation

Refer to the torch_migraphx repository for more information on local builds and Docker environments.