Skip to content

AMD ROCm for Linux Guide

This guide is a step-by-step instruction for setting up AMD ROCm on Linux for use with SD.Next

For official AMD ROCm documentation, visit AMD ROCm Documentation, AMD ROCm Installation Guide and AMD GPU Driver

Warning

Note that common amdgpu-install method is no longer supported or used with ROCm 10.x and later versions

Prepare System

Before installation of AMD ROCm, make sure your system is prepared with the necessary dependencies:

sudo apt update
sudo apt install sudo wget gpg perl
sudo apt install libatomic1 libquadmath0

Refer to your distribution for specific installation commands

ROCm Installation

Note

This guide provides info for installing ROCm 10.1.0, update version number as needed for newer versions
To install older versions of ROCm such as 7.x or 6.x, refer to the corresponding installation guides on the official AMD ROCm documentation site

Install AMDGPU and ROCm using the AMD's official installer script

wget https://stable.repo.amd.com/rocm/core/linux-installers/rocm-installer-10.1.0-5.run
bash rocm-installer-10.1.0-5.run deps=install amdgpu rocm gfx=all gpu-access=user

Tip

If you have a kernel > 6.9, you can skip the installation of the amdgpu module
Users on older Ubuntu versions can install the linux-hwe kernel package to get a more up to date version

Alternative means of installation are described in the official AMD ROCm documentation

Tip

To reduce installation size, you can specify a particular GPU architecture using the gfx parameter during installation
For example, instead of gfx=all, you can specify a particular GPU architecture like gfx=gfx1201 For a full list of GPU names and corresponding architecture strings, refer to documentation

And modify your system environment variables as needed to include ROCm paths
This is required so system can locate hipcc compiler required for triton operations
For example, you may need to add the following lines to your ~/.bashrc:

export ROCM_PATH=/opt/rocm
export PATH=$ROCM_PATH/bin:$PATH
export LD_LIBRARY_PATH=$ROCM_PATH/lib:$LD_LIBRARY_PATH

Important

Make sure to reboot your system after ROCm installation to ensure all changes take effect

Torch Installation

SD.Next auto-detects presence of ROCm and installs appropriate version of torch for ROCm 6.x, 7.x and 10.x on first startup
For typical usage, you do not need to manually install torch for ROCm as SD.Next will handle it automatically

If you want to use latest nightly builds of torch for ROCm,
you can force-reinstall it by starting SD.Next with the --reinstall --use-nightly flag

If you want to use a specific version of torch for ROCm,
you can uninstall version installed by SD.Next and install the desired version manually within the SD.Next virtual environment

For example:

source ./venv/bin/activate
pip uninstall torch torchvision
pip install torch==2.15.0+rocm10.0 torchvision==0.29.2+rocm10.0 --index-url https://download.pytorch.org/whl/rocm10.0
deactivate

For details, refer to AMD Torch ROCm Install Documentation