Skip to content

Instantly share code, notes, and snippets.

@FCLC
Last active April 26, 2024 00:12
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save FCLC/8c1f4d28d65a2e6d40b82f82c8fe4e08 to your computer and use it in GitHub Desktop.
Save FCLC/8c1f4d28d65a2e6d40b82f82c8fe4e08 to your computer and use it in GitHub Desktop.
Installing amdgpu-pro on popOS to enable OpenCL, ROCm and HIP

currently out of date as of September 2022, needs a fresh update

TLDR; edit the amdgpu-install script to add pop as supported debian distribution, comment out check for linux-modules-extra-[versions] since they're provided by linux-modules [per Jeremy Solle of System_76], then run with --no-dkms

3 EDIT: 4 things need to be done.

Problem 1) Pop!_OS not valid install target "Unsupported OS: /etc/os-release ID 'pop'" The issue as of now is that amdgpu-install doesnt recognize pop as a valid installation candidate. Solution is to add pop as a valid target in the amdgpu-install script.

As of Dec 1 2021: change line 241 to include | pop Pop!_OS will then be seen as a valid installation target

Problem 2) No linux-modules-extra package available

Package linux-modules-extra-5.15.5-76051505-generic is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'linux-modules-extra-5.15.5-76051505-generic' has no installation candidate

Pop!_OS includes what would normally be in linux modules extra in the standard linux-modules package, then marks linux-modules-extra as a virtual package [see https://twitter.com/jeremy_soller/status/1466061665548390402?s=20]

Solution is to remove the check by commenting out lines 360-363 Edit:the lines may have moved depending on version. You're loocking for the lines referencing linux-modules-extra

Problem 3) DPKG error kernel package not supported

ERROR (dkms apport): kernel package linux-headers-5.15.5-76051505-generic is not supported
Error! Bad return status for module build on kernel: 5.15.5-76051505-generic (amd64)
Consult /var/lib/dkms/amdgpu/5.11.32-1337797/build/make.log for more information.
dpkg: error processing package amdgpu-dkms (--configure):
 installed amdgpu-dkms package post-installation script subprocess returned error exit status 10
Errors were encountered while processing:
 amdgpu-dkms
E: Sub-process /usr/bin/dpkg returned an error code (1)

DKMS isnt needed, we're better off using the in kernel module already provided

Solution is to use the --no-dkms flag at install time

EDIT:2022/03/24

Problem 4) With the move from Hirsute to Impish, some repositories are no longer available and will cause the building of rocm-llvm to fail. The missing packages on a near vanilla instalation are: python-six, libgcc-5 series and libgcc-7 series.

As of now the best way to deal with this is to add the legacy LTS repositories from 18.04 LTS which have all missing packages to our apt sources and proceed that way.

Edit /etc/apt/sources.list and add the line deb http://mirrors.kernel.org/ubuntu bionic main universe

sudo apt update

Then run the command as before with the relevant options.

As always this isnt fully sanctioned and supported by AMD or System76 (creators and maintaners of Pop!_OS) but being as this is downstream Debian/Ubuntu you shouldn't run into any issues. No guarentees, but it seems fine on my end.

@FCLC
Copy link
Author

FCLC commented Dec 1, 2021

As of Dec 01 2021, the installation is functional and is able to complete the entire phoronix opencl suite

@FCLC
Copy link
Author

FCLC commented Jan 21, 2022

Update to include that specific line numbers may change for problem 2

@arnolddej
Copy link

Good day, followed your guide today but with this setup:

❯ neofetch
OS: Pop!_OS 21.10 x86_64
Host: MS-7C37 2.0
Kernel: 5.16.11-76051611-generic
Uptime: 1 hour, 3 mins
Packages: 3421 (dpkg), 33 (flatpak)
Shell: bash 5.1.8
Resolution: 2560x1440, 2560x1440
DE: GNOME 40.5
WM: Mutter
WM Theme: Pop
Theme: Pop-dark [GTK2/3]
Icons: Pop [GTK2/3]
Terminal: gnome-terminal
CPU: AMD Ryzen 9 5900X (24) @ 3.700GH
GPU: AMD ATI Radeon RX 6800/6800 XT /
Memory: 4292MiB / 15982MiB

I've included 'pop' to the amdgpu-install script.

But when running it with amdgpu-install --no-dkms

I get the following, different, error:

_Skipping all hits

Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
python3-six : Breaks: python (< 2.7.18)
python3-yaml : Breaks: python (< 2.7.18)
rocm-llvm : Depends: libstdc++-5-dev but it is not installable or
libstdc++-7-dev but it is not installable
Depends: libgcc-5-dev but it is not installable or
libgcc-7-dev but it is not installable
Recommends: gcc-multilib but it is not going to be installed
Recommends: g++-multilib but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages._

Any suggestions?

@FCLC
Copy link
Author

FCLC commented Mar 22, 2022

The following packages have unmet dependencies: python3-six : Breaks: python (< 2.7.18) python3-yaml : Breaks: python (< 2.7.18) rocm-llvm : Depends: libstdc++-5-dev but it is not installable or libstdc++-7-dev but it is not installable Depends: libgcc-5-dev but it is not installable or libgcc-7-dev but it is not installable Recommends: gcc-multilib but it is not going to be installed Recommends: g++-multilib but it is not going to be installed E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages._

Any suggestions?

Gcc-multilib typically means having 32 bit support in your gcc, and its requisite files (headers and so on). If you don't have them, that may cause issues.

Something you can attempt is to change the internal checks within the script to look for version 6 in addition to version 5 and 7. If that does or doesnt work let me know; I've been occupied with AVX512 for Sapphire Rapids of late, so haven't been looking at ROCm much. (in part because after 3 years AMD still doesnt have RDNA 1 support in the stack)

@FCLC
Copy link
Author

FCLC commented Mar 23, 2022

I'm able to recreate the issue on the latest release, looking into it

Edit: installing python-six fixes the python issues

Edit2: installing the recommended multilibs is good practice anyway, but more relevant is running amdgpu-install --dryrun --no-dkms --no-32 which returns the expected commands from the script so we can find out where things are going wrong.

sudo apt-get update
sudo apt-get install amdgpu-lib rocm-opencl-runtime rocm-hip-runtime
sudo ln -sf /usr/bin/amdgpu-install /usr/bin/amdgpu-uninstall

the update we can ignore, the soft linking at the end the same.

then it's a question of which of the 3 (if not all? is causing the issue)

Edit3: after testing the 3, the first 2 proceed with no issue, the problems are related to the hip runtime. Something I notice when looking at the package data (apt info [package name]) is that it requires rocm-core, rocm-language-runtime, rocminfo and hip-rocclr. Of the first 3, 2 weren't installed and the fourth is a virtual package.

installing the 3rd (rocminfo) didnt fix the issues.

looking further into it, the package does exist in the ubuntu repoes.... https://packages.ubuntu.com/impish/amd64/libstdc++5/download. (notice this is the lib, not the dev headers.)

and checking /etc/apt/sources.list.d/system.sources for impish to include main and universe both are there

Further down the rabbit hole, the dev headers are only available in the bionic beaver release repos of ubuntu, see https://packages.ubuntu.com/bionic/amd64/libstdc++-5-dev/download

therefore as a workaround, we could work with dpkg directly and do: wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-3.3/libstdc++5_3.3.6-30ubuntu2_amd64.deb && sudo dpkg --install http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-3.3/libstdc++5_3.3.6-30ubuntu2_amd64.deb for each of the pkgs, but that would be a miserable endeavour requiring dozens of individuals packages and their sources.

in this case I'm thinking the way to do it is to add the 18.04 LTS repository to sources.list.

this will probably error out with a "no_pubkey error" because kernel.org, debian and ubuntu aren't always upto date with sharing their keys with each other.

for the kernel.org mirror the command was sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32, but just switch out the last part with the key you're missing.

After all of the above debugging running amdgpu-install --no-32 --no-dkms was able to successfully install.

@arnolddej
Copy link

Thanks for checking it out! I will try this week if I can get it done.

@FCLC
Copy link
Author

FCLC commented Apr 7, 2022

Thanks for checking it out! I will try this week if I can get it done.

Did the above end up working for you? if so let me know so I can mark this off as functional!

@RocketPhoenix
Copy link

I'm in PopOS 22.04, and I think I've almost got this working. A new issue seems to be that the legacy repository is no longer secured for some reason. Running sudo apt update --allow-insecure-repositories is a workaround for updating, however there does not seem to be a way to run amdgpu-install while allowing insecure repositories, as running sudo amdgpu-install --usecase=rocm --no-dkms --allow-insecure-repositories reads "N: Updating from such a repository can't be done securely, and is therefore disabled by default.".
Is there a way to add --allow-insecure-repositories into the script itself?

Also just to be safe, the 4 commented out lines look something like this, right?

  if apt-cache show linux-modules-extra-$(uname -r) &>/dev/null
  then
  	PACKAGES=(${PACKAGES[*]} linux-modules-extra-$(uname -r))
  fi

@FCLC
Copy link
Author

FCLC commented Apr 29, 2022

I'm in PopOS 22.04, and I think I've almost got this working. A new issue seems to be that the legacy repository is no longer secured for some reason. Running sudo apt update --allow-insecure-repositories is a workaround for updating, however there does not seem to be a way to run amdgpu-install while allowing insecure repositories, as running sudo amdgpu-install --usecase=rocm --no-dkms --allow-insecure-repositories reads "N: Updating from such a repository can't be done securely, and is therefore disabled by default.". Is there a way to add --allow-insecure-repositories into the script itself?

Also just to be safe, the 4 commented out lines look something like this, right?

  if apt-cache show linux-modules-extra-$(uname -r) &>/dev/null
  then
  	PACKAGES=(${PACKAGES[*]} linux-modules-extra-$(uname -r))
  fi

I'm a little busy at the moment on other projects, I'll try to get back to you in a few days time.

In the meantime, a very temporary workaround that should get you going temporarily is to change PKGUPDATE="apt-get update" to "apt-get update --allow-insecure-repositories" . do this below the insertion of | pop into the OS options

@FCLC
Copy link
Author

FCLC commented May 10, 2022

@RocketPhoenix did the above work for you?

@kaydeejay
Copy link

I've been using an old version of blender because I can render with opencl, which disappeared from newer versions.
I was able to successfully get opencl running without conflicts by following this guide.

Newer versions of blender use HIP. Will following this guide allow me to do render with newer blender versions?

Also, I'm running pop 22.04 so I will also probably run into the insecure-repositories problem, is there another fix for that or is allowing insecure repos still the way to solve?

@FCLC
Copy link
Author

FCLC commented Jul 23, 2022

I've been using an old version of blender because I can render with opencl, which disappeared from newer versions. I was able to successfully get opencl running without conflicts by following this guide.

Newer versions of blender use HIP. Will following this guide allow me to do render with newer blender versions?

Also, I'm running pop 22.04 so I will also probably run into the insecure-repositories problem, is there another fix for that or is allowing insecure repos still the way to solve?

depends partially on if your GPU has proper HIP support.

the RX 5000 series has no HIP support at all

@kaydeejay
Copy link

I've been using an old version of blender because I can render with opencl, which disappeared from newer versions. I was able to successfully get opencl running without conflicts by following this guide.
Newer versions of blender use HIP. Will following this guide allow me to do render with newer blender versions?
Also, I'm running pop 22.04 so I will also probably run into the insecure-repositories problem, is there another fix for that or is allowing insecure repos still the way to solve?

depends partially on if your GPU has proper HIP support.

the RX 5000 series has no HIP support at all

Good to know, I'm using a RX 5600xt. Guess I'll just stick with old blender and opencl. Thank you!

@FCLC
Copy link
Author

FCLC commented Jul 25, 2022

Seems there's a new issue now as of 25/07/2022:

Python breaks when trying to run/install if you're also trying to install ROCm/HIP libraries

Looking into this now

@hanzy1110
Copy link

hanzy1110 commented Aug 14, 2022

Hi! I think I've run into the same python issue in Pop 22.04
Here's the output of amdgpu-install:

The following packages have unmet dependencies:
python3-six : Breaks: libpython-stdlib (< 2.7.18) but 2.7.15rc1-1 is to be installed
Breaks: python-minimal (< 2.7.18) but 2.7.15
rc1-1 is to be installed
python3-yaml : Breaks: libpython-stdlib (< 2.7.18) but 2.7.15rc1-1 is to be installed
Breaks: python-minimal (< 2.7.18) but 2.7.15
rc1-1 is to be installed
rocm-gdb : Depends: libpython3.8 but it is not installable
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

Any news?
Edit: properly followed the guide and the error changed

@limzykenneth
Copy link

The instructions in this comment works for me in setting up ROCm and eventually also running tensorflow through it. Further up the same thread, the advice on installing python 3.8 through deadsnakes also helped address the python dependency as well.

Running Pop 22.04 with RX6800, tested working all the way to installing tensorflow-rocm and importing it into python. Haven't tried running full ML code yet (it probably will work?) but it is the furtherest I got to getting ROCm to work on 22.04.

@siebtel
Copy link

siebtel commented Oct 28, 2022

Have it worked? @limzykenneth
For me, I had a problem installing it because of the kernel, mine is 6.x.x, and the supported one is up to 5.13

@limzykenneth
Copy link

It's tested and working fully for me, running pytorch and tensorflow without problems using GPU acceleration.

@Calcium3d
Copy link

Is there still no support for HIP rendering in blender on 5000 series?

@FCLC
Copy link
Author

FCLC commented Jan 5, 2023

Is there still no support for HIP rendering in blender on 5000 series?

If you're willing to build HIP yourself from source, then yes, Blender HIP can work on 5k series

@sajibsrs
Copy link

I was able to run both OpenCL and HIP on my RX 5500 XT (Pop!_OS)

@hanzy1110
Copy link

hanzy1110 commented Jan 15, 2023 via email

@sajibsrs
Copy link

sajibsrs commented Jan 15, 2023

First followed this tutorial. After that I had working OpenCL. Then I ran sudo apt-get install amdgpu-lib rocm-opencl-runtime rocm-hip-runtime. Reboot was not required at this point. That's it. Everything worked without a problem. I've tested blender render with HIP.

@arawup
Copy link

arawup commented Feb 9, 2023

First followed this tutorial. After that I had working OpenCL. Then I ran sudo apt-get install amdgpu-lib rocm-opencl-runtime rocm-hip-runtime. Reboot was not required at this point. That's it. Everything worked without a problem. I've tested blender render with HIP.

Can confirm that this works.

Warning shows up in:

  • Flatpak

Detects GPU(selectable in System):

  • PPA (when trying to render it will warn: HIP hipcc compiler not found. Install HIP toolkit in default location)

Renders(fully works):

  • tar
  • Snap

GPU: Radeon 5700
#wget link is from wget https://repo.radeon.com/amdgpu-install/ As sometimes the driver page isn't up to date. Also, the Radeon repo did have connection issues when I tried wget from it, just try it at another time.

wget https://repo.radeon.com/amdgpu-install/22.40/ubuntu/jammy/amdgpu-install_5.4.50401-1_all.deb --output-document ~/Desktop/amdgpu-install.deb

chmod u+x ~/Desktop/amdgpu-install.deb
sudo apt install ~/Desktop/amdgpu-install.deb
sudo sed -i 's/ID=pop/ID=ubuntu/g' /etc/os-release

sudo amdgpu-install --usecase=opencl --no-dkms
sudo usermod -a -G video $LOGNAME
sudo usermod -a -G render $LOGNAME
sudo apt install opencl-headers ocl-icd-libopencl1 clinfo -y

sudo sed -i 's/ID=ubuntu/ID=pop/g' /etc/os-release
clinfo | grep -i opencl
sudo apt-get install amdgpu-lib rocm-opencl-runtime rocm-hip-runtime -y
# rebooted

@ju8crafter-jaXnein
Copy link

Hello, Ive been trying to install ROCm/HIP for quite some time now to enable Blender rendering and tensorflow for my 7900xtx, but i didnt have any luck yet.
Im not sure if this here is the right place but maybe someone got an idea what to do next anyway.

On my current try i managed to install it properly at first glance using amdgpu-install --no-dkms --usecase=rocm with the most recent version of amdgpu-install (6.0.60002-1718217.22.04). But when it is installed the system wont start properly anymore, first i see the normal grey screen then a glitchy screen and after that the "Oh no!" screen comes. After reading the comment from doc_willis on this reddit post from someone with a similar issue, i enabled gdm debug and looked through the journal journalctl | grep gdm and found stuff like MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri) (zink apparently could also not be found). After looking i found the stuff though under /usr/lib/x86_64-linux-gnu/dri so i tried what happens when having a symlink /usr/lib/dri -> /usr/lib/x86_64-linux-gnu/dri but that resulted in a different error.
pretty much this
After fixing that i got the previous ones again but slightly different, now it complained about a missing symbol or something
libEGL warning: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: undefined symbol: amdgpu_va_get_start_addr (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri) and from here i didnt know how to continue, so i went back into recovery mode and did amdgpu-install --uninstall to get rid of it all and make my system work normally again.

Now my questions are has anyone experienced such breaking aswell, if anyone sees a mistake in my doings, has an idea how to fix this properly or if we have to wait for another pop os update to make it work again, as apparently according to the comment from gordesky1 (mentioned reddit post) it worked until a recent update broke it.

Im thankful for any idea/suggestion that might make it finally work.

neofetch:
OS: Pop!_OS 22.04 LTS x86_64
Host: X670E Taichi
Kernel: 6.6.10-76060610-generic
Uptime: 8 mins
Packages: 3371 (dpkg), 24 (flatpak)
Shell: bash 5.1.16
Resolution: 1920x1080, 1920x1080
DE: GNOME 42.5
WM: Mutter
WM Theme: Pop
Theme: Pop-dark [GTK2/3]
Icons: Pop [GTK2/3]
Terminal: gnome-terminal
CPU: AMD Ryzen 9 7900X (24) @ 5.733GH
GPU: AMD ATI 03:00.0 Device 744c
GPU: NVIDIA GeForce RTX 3060 Lite Has
Memory: 5437MiB / 63410MiB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment