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.
amdgpu-install
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 forubuntu, and add|popto the list (|reads "or").Search for
linux-modules-extraand replace the entire functiondebian_build_package_list()with, on one line,function debian_build_package_list() { echo 'empty function'; }Save and quit
Python 3.8
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
ROCm Repositories and Package Editing
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
Edit Package 1/2
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.
Edit Package 2/2
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
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
PyTorch Postscript
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())
Answer from Rasmus on askubuntu.comInstalling ROCm / HIPLIB on Ubuntu 22.04 - Linux - Framework Community
[Issue]:
A video guide for installing ROCm drivers and Stable Diffusion in Linux for AMD GPU (Automatic1111 and ComfyUI)
Getting started with rocM
Videos
I recently configured ROCm on AMD GPU and Ubuntu, and I though this might come in handy for someone. Feel free to give me feedback if it still doesn't work for you.
Here is the gist: https://gist.github.com/jurgonaut/462a6bd9b87ed085fa0fe6c893536993
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.
amdgpu-install
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 forubuntu, and add|popto the list (|reads "or").Search for
linux-modules-extraand replace the entire functiondebian_build_package_list()with, on one line,function debian_build_package_list() { echo 'empty function'; }Save and quit
Python 3.8
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
ROCm Repositories and Package Editing
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
Edit Package 1/2
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.
Edit Package 2/2
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
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
PyTorch Postscript
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
https://www.youtube.com/watch?v=QEbI6v2oPvQ
I had a lot of trouble setting up ROCm and Automatic1111. I tried first with Docker, then natively and failed many times. Then I found this video. It has a good overview for the setup and a couple of critical bits that really helped me. Those were the reinstallation of compatible version of PyTorch and how to test if ROCm and pytorch are working. I still had a few of those Python problems that crop up when updating A1111, but a quick search in A1111 bug reports gave work arounds for those. And a strange HIP hardware error came at startup, but a simple reboot solved that.
Also he says he couldn't make it work with ROCm 5.7, but for me now 2 months later, ROCm 5.7 with 7900 XTX and Ubuntu 22.04 worked.
And coming from a Windows DirectML setup, the speed is heavenly.
Hello,
I recently acquired a new PC including the 7900 xtx and 7800x3d and wanted to try to run rocm. I already found the documentation:
https://rocm.docs.amd.com/en/latest/index.html
However i wanted to ask if there is a community that is active and discusses current progression/bugs etc. I honestly cant find much information online however it is probably a relativley niche topic since most people use nvidia.
I will also probably have to install a supported OS and the respective kernel accourding to : https://rocm.docs.amd.com/en/latest/release/gpu_os_support.html
How accurate is this? I currently have Ubuntu 22.04.3 with kernel 6.2.0-26-generic, its neither in the supported nor unsupported tab.
Also what about the disadvantages of dockerization? It sounds pretty good and useful but will the perfomance suffer? Im familiar with docker to some degree but im kinda sceptical how it works to pass the actual physcial gpu to the Container.
Also i would be grateful for every information/source you can give me. Also grateful for every advice.