Install Torch-MIGraphX#
2026-11-26
3 min read time
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 7.14.1 using pip.
Prerequisites#
Torch-MIGraphX 1.2 is supported on the same AMD GPUs as MIGraphX 2.16.0. See the MIGraphX installation page for the list of supported architectures and the ROCm 7.14.1 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 7.14.1. Select pip as the installation method and install ROCm 7.14.1 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.
Activate the ROCm 7.14.1 virtual environment you created while installing ROCm using pip.
source .venv/bin/activate
Note
Substitute
.venvwith the path to your virtual environment if you used a different name or location.Install a ROCm-enabled PyTorch release into the environment. See Install PyTorch for ROCm, select pip and ROCm 7.14.1 on the selector panel, and install into the same virtual environment. The
torch_migraphxwheel in the next step requires a matching ROCm 7.14.1 installation.Install the
torch_migraphxwheel. This also installs the matching MIGraphX 2.16.0 wheel.python -c "import torch; print(torch.__version__); assert torch.version.hip, 'ROCm PyTorch required'" && \ python -m pip install --extra-index-url https://rocm.frameworks.amd.com/whl-multi-arch/ \ "torch_migraphx==1.2+rocm7.14.1"
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
Trueif the MIGraphX backend is registered as expected.Important
If either command fails with
libhiprtc.so.7: cannot open shared object file, updateLD_LIBRARY_PATHto link to the required ROCm libraries. ROCm’s pip wheels place their shared libraries inside your virtual environment’ssite-packagesinstead of/opt/rocm, so add them toLD_LIBRARY_PATHbefore running the commands. Run this command again in each new shell session after activating the virtual environment.ROCM_SDK_CORE=$(python3 -c "import _rocm_sdk_core, os; print(os.path.dirname(_rocm_sdk_core.__file__))") ROCM_SDK_LIBRARIES=$(python3 -c "import _rocm_sdk_libraries, os; print(os.path.dirname(_rocm_sdk_libraries.__file__))") export LD_LIBRARY_PATH=$ROCM_SDK_CORE/lib:$ROCM_SDK_CORE/lib/rocm_sysdeps/lib:$ROCM_SDK_LIBRARIES/lib:$LD_LIBRARY_PATH
Uninstall Torch-MIGraphX#
Remove the package from your virtual environment.
python -m pip uninstall torch_migraphx
To also remove the MIGraphX library that was installed as a dependency:
python -m pip uninstall migraphx
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.