The AMD installation instructions for ROCm 5.2.1 state that ROCm is only compatible with Ubuntu 20.04
Can I still install and use it on Ubuntu 22.04?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityThe AMD installation instructions for ROCm 5.2.1 state that ROCm is only compatible with Ubuntu 20.04
Can I still install and use it on Ubuntu 22.04?
Yes, I believe you can. Doing the following, I a least successfully installed ROCm 5.1.1 on the Ubuntu-based Pop!_OS 22.04. I am now able to run PyTorch computations on my GPU, an AMD RX 6800 XT.
I essentially followed this comment, with a bit of extras. See also that comment for reasons for some steps.
Some places below, you must replace 5.1.1
with the version you want.
We going to use a terminal. So open one. Create a directory to work in:
mkdir ~/ROCm && cd ~/ROCm
Update, then download the .deb
file for amdgpu-install
, and install it (link gotten from AMD):
sudo apt update
wget https://repo.radeon.com/amdgpu-install/22.20.1/ubuntu/focal/amdgpu-install_22.20.50201-1_all.deb
sudo apt-get install ./amdgpu-install_22.20.50201-1_all.deb
We now have to edit amdgpu-install
:
sudo gedit /usr/bin/amdgpu-install
Pop!_OS is not listed as supported by amdgpu-install
, so we add it: Search for ubuntu
, and add |pop
to the list (|
reads "or").
Search for linux-modules-extra
and replace the entire function debian_build_package_list()
with, on one line,
function debian_build_package_list() { echo 'empty function'; }
Save and quit
Packages in the next steps require that we have also the older Python 3.8 installed. So:
sudo add-apt-repository --yes ppa:deadsnakes/ppa
sudo apt-get update
sudo apt install --yes python3.8
Next, we add the desired ROCm repository. The link is relative to the ROCm version to be installed, so look up the base URL here.
echo 'deb [arch=amd64] <Release-1 specific rocm baseurl> ubuntu main' | sudo tee /etc/apt/sources.list.d/rocm.list
sudo apt update
I used ROCm 5.1.1, so I used specifically
echo 'deb [arch=amd64] https://repo.radeon.com/rocm/apt/5.1.1 ubuntu main' | sudo tee /etc/apt/sources.list.d/rocm.list
The download the .deb
file for the ROCm package:
apt download rocm-llvm5.1.1
We need to edit this package before it will install. So we unpack, unpack and edit (by <tab>
I mean press Tab
to autocomplete):
ar x rocm-llvm<tab>
tar xf control.tar.xz
gedit control
In control
, edit the Depends
line to
Depends: python3, libc6, libstdc++6|libstdc++8, libstdc++-5-dev|libstdc++-7-dev|libstdc++-10-dev, libgcc-5-dev|libgcc-7-dev|libgcc-10-dev, rocm-core5.1.1
I.e., add |libstdc++-10-dev
and |libgcc-10-dev
in the appropriate positions.
Then repack:
tar c postinst prerm control | xz -c > control.tar.xz
ar rcs rocm-llvm5.1.1_14.0.0.22114.50101-48_amd64.deb debian-binary control.tar.xz data.tar.xz
Great! Now, we install the possible dependencies we just added, and rocm-core5.1.1
:
sudo apt install libstdc++-10-dev libgcc-10-dev rocm-core5.1.1
Now the downloaded package installed for me with
sudo dpkg -i rocm-llvm<tab>
Super.
Now we download, identically edit, and repack another package, openmp-extras5.1.1
:
mkdir openmp && cd openmp
apt download openmp-extras5.1.1
ar x openmp<tab>
tar xf control.tar.xz
gedit control
Edit Depends
line, add |libstdc++-10-dev
and |libgcc-10-dev
as before. Save, close, repack, install a dependency, and then the package with:
tar c control | xz -c > control.tar.xz
ar rcs openmp-extras5.1.1_13.51.0.50101-48_amd64.deb debian-binary control.tar.xz data.tar.xz
sudo apt install rocm-device-libs5.1.1
sudo dpkg -i openmp<tab>
I hope that all went smoothly.
Install ROCm with the usecases you need. Mine are ROCm and HIP. See amdgpu-install --help
for options.
sudo amdgpu-install --rocmrelease=5.1.1 --usecase=rocm,hip --no-dkms
Cool.
Now a final piece of setup: Add your user to the render
and video
groups:
sudo usermod -a -G render $LOGNAME
sudo usermod -a -G video $LOGNAME
and reboot.
Once rebooted, check that ROCm is loaded with
rocminfo
Hurra!, I hope, and time for cleaning:
rm -rf ~/ROCm
Note: Be sure that the ROCm version you installed is supported by Pytorch. At time of writing, Stable supports ROCm 5.1.1, Nightly supports 5.2. Check the PyTorch Start Locally page.
I needed ROCm for PyTorch, installed with
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/rocm5.1.1
I then got verification that I could use my GPU for computation by running
python3
import torch
torch.cuda.is_available()
torch.cuda.get_device_name(torch.cuda.current_device())
Update: as of ROCm 5.3.0, support for Ubuntu 22.04 has been added.
Installation guide: https://docs.amd.com/bundle/ROCm-Installation-Guide-v5.3