Install AMDGPU drivers on Ubuntu 20.04

Holdolin

Hard DC'er of the Month February 2021
Joined
Dec 19, 2020
Messages
60
So I was discussing GPUs in another thread, which was already off-topic so I decided to make a new one to show how I ended up getting AMD drivers to work in Ubuntu 20.04. In the couple months I've been back crunching I've realized by both first-hand experience and several threads in both MW and Einstein forums there are questions/confusion about properly getting AMD drivers installed on Ubuntu Linux. From my research it seems the problem is the kernel/driver version not being right. It's like hitting a moving target, as Ubuntu keeps updating the kernel and it causes problems with drivers. I'll be blunt, even though I knew this to be the root of the problem (no pun intended) the final solution was not mine. I would like to give a shout out to Keith Myers for what ended up the final solution. I don't think he visits this site, but I still want to thank the man for his idea. Anyway, before this intro turns into a flippin novel, let's get to the goods, shall we? I will start as a bare-metal install, but include directions if you already have a running system.

First, make sure you have the original release of 20.04. If you do not, you can get it here: http://old-releases.ubuntu.com/releases/20.04/ubuntu-20.04-desktop-amd64.iso

Before you begin the install, ensure your internet is disabled. Unplug the cable or disable the Wi-Fi. If the installer has access to the internet it will update core packages as part of the install, which includes the kernel: the one thing we DON'T want updated.

On startup, you will be given the option to try Ubuntu or install it. Select install.

Next, configure the keyboard as needed. It always detects mine just fine, but that's just my luck I guess.

Next, you have the option to do a normal installation or a minimal. If you are using the box as a dedicated cruncher or simply want to select your own packages after install then select minimal. If you prefer a fully-functioning system then by all means, normal install.

You then get offered choices as to where/how to install. Since I always either use a blank disk or one which I am ok with overwriting, I choose erase disk and install Ubuntu.

Set your time zone. Normally, with an internet connection the installer detects it for you, but for this particular situation we have no internet.

Now, set names and passwords.

Finally, reboot into your new system.

On the initial login you get a welcome screen, set the settings as you see fit.

Now, let's get the internet up. When you plug in the cable the system will automatically try and grab IP information from a DHCP server. However, if you prefer a static IP address you can set that by clicking on the icon in the upper right corner with the 3 little computers. From the dropdown menu, select wired settings (assuming wired internet). On the new window, click on the cog wheel next to the ethernet connection. Click on the IPv4 tab and set the IP information as applicable. Click the apply button. To ensure the network is updated, toggle the ethernet connection off then back on. Again, the static IP is optional, but quite handy if you intend to use remote machines/tools to monitor or control your system.

Now, open a terminal so we can get to the "fun stuff" :p To open a terminal, click on the dots icon in the lower left of your screen. Several apps will show up on your screen. If the terminal app is not there just start typing terminal and it will show up. Right-click on the terminal icon and add it to your quick bar (you'll be using it after reboots, so it's easier to just have it handy). Now left-click on the icon to launch the terminal. Since we will be working in the terminal, I'd like to point out that tab completion works in the terminal like most word processing apps. Not only can it save you time, you can use it as a "cheat" if you're not quite sure how something is spelled or what version something is.

Ok, now that we're in the terminal let's first make sure we're using the proper kernel. We check that with the command as follows:
Code:
uname -r
The output should read 5.4.0-26-generic

Now we are going to update the repository information to ensure the next step allows the system to find the packages we are going to block from updating:
Code:
sudo apt update

Alrighty, now for the trick that makes this whole driver thing work. We are going to tell Ubuntu to NOT update the kernel. A note to be aware: Ubuntu is slow to understand no means no, so don't worry when the next step updates the kernel even though this step told it not to:
Code:
sudo apt-mark hold linux-generic linux-image-generic linux-headers-generic
this command should generate the following output:
Code:
linux-generic set on hold.
linux-image-generic set on hold.
linux-headers-generic set on hold.

Alrighty, let's upgrade the system software:
Code:
sudo apt upgrade
This will upgrade all the currently installed software.

As I mentioned earlier, Ubuntu is slow to understand no means no, so we need to uninstall the new kernel it just installed. If you missed what updated kernel was just installed, the easy command I use is:
Code:
sudo update-grub
You should see 2 kernels, the 5.4.0-26-generic kernel, and a new one. We need to get rid of that new kernel before we reboot, else the system will reboot into the newer kernel and it's more work to delete the kernel that's currently loaded. As of this writing, the command to scrap the new kernel is
Code:
sudo apt remove linux-image-5.8.0-38-generic linux-headers-5.8.0-38-generic linux-modules-5.8.0-38-generic linux-image-unsigned-5.8.0-38-generic
If you are one that pays attention, or just likes to know, linux-image-unsigned-5.8.0-38-generic wasn't installed (yet). Adding that to the end basically tells Ubuntu no means NO. Do not update the <radio edit> kernel. If you hadn't added it, it would have installed the unsigned image and you'd have had to run the command again to remove the unsigned image.

Alright, let's reboot the system to apply all the updates:
Code:
sudo reboot

Now, let's verify we are still on the proper kernel
Code:
uname -r
We should still be on the 5.4.0-26-generic kernel

There will be "leftover" software still on the system but not needed. Purge it as follows:
Code:
sudo apt autoremove
Just to be safe, let's reboot once more. Likely, you could have run the autoremove command before the last reboot, but while setting up my sytem I didn't realize there was software that needed to be removed. In any event, reboot the system since on my test there was kernel software, and even if not in use, the driver install will try to install for any kernel on the system and it has caused problems on my systems and I tested and documented this procedure.

Ok, now we're booted into our system and ready to get some driver love going. Grab the driver here Click on Ubuntu x86 64, then scroll down to Radeon™ Software for Linux® Driver for Ubuntu 20.04 (Revision number 20.20) Click the download button and pull in the driver. I would loved to have just linked the driver download itself but AMD apparently don't like it. Make note of where the driver downloaded to, default is the Downloads folder.

Assuming you downloaded into the default folder, navigate there in your terminal:
Code:
cd Downloads

Now we can extract the archive
Code:
tar -Jxv
and hit tab. Since this is a fresh install, there should be exactly 1 file in your downloads folder, so using tab completions will select the filename even with nothing yet typed as it's the only possibility. Now move into the new directory
Code:
cd
and tab

Now for the final command (except the reboot): For the Vega and new cards
Code:
./amdgpu-pro-install -y --opencl=pal
and for cards older than Vega
Code:
./amdgpu-pro-install -y --opencl=legacy
This will do all the dirty work.

After the install has finished, reboot the system.

EIDT1:

Have a Vega or VII and it's running hotter than the blazes of damdation? There are solutions for that.

There is an app called Ricks GPU Utilities (thanks biodock).

Secondly, an app called radeon-profile. This is the app I use on my crunchers.

End EDIT1

Oh, I almost forgot: If you have a running system with a more recent kernel than the 5.0.4-26, instead of the part where you install the system, you need to boot into the target kernel. To do so, hit the esc key as the system boots. This will bring you to a screen where you can select advanced boot options. There you will have the option to choose the kernel you boot into. Select the 5.4.0-26. Once booted in, delete all but the running kernel using the above methods. Fair warning: I haven't tried it myself, but it should work in theory. As always, back up your stuff before trying such things so if it explodes your system you can start at the beginning of this guide after all :)

And there you have it friends. It's been a loong couple of weeks, so i'm hitting the hay. If you have any questions or feedback by all means. This includes readability since this is the first guide I've ever written :)
 
Last edited:
Looks great, very detailed and easy to follow. I have a couple machines running AMD cards that I'm running Windows on because I couldn't get AMD drivers functioning properly in Linux, so I will definitely try this in the next few days and report back with results. Thanks!
 
Thanks for the clear instructions. I've been exploring options for my radeon VII on linux off and on for months. The 19.50 driver version was the last version that accepted the --no-dkms option for the "pro" installation script. I downloaded the 20.40 version the other day for installation on a fresh install of Ubuntu 20.04.1 LTS.

This failed to run. The "pro script" requires dkms
./amdgpu-pro-install -y --opencl=pal --headless --no-dkms

Like you said, this failed with a dkms module installation error.
./amdgpu-pro-install -y --opencl=pal --headless

I decided to ditch the "pro" script and try the amdgpu-install script with the no-dkms option.
./amdgpu-install -y --opencl=pal --headless --no-dkms

This worked on the 5.8 kernel. :)
 
Thanks for the clear instructions. I've been exploring options for my radeon VII on linux off and on for months. The 19.50 driver version was the last version that accepted the --no-dkms option for the "pro" installation script. I downloaded the 20.40 version the other day for installation on a fresh install of Ubuntu 20.04.1 LTS.

This failed to run. The "pro script" requires dkms
./amdgpu-pro-install -y --opencl=pal --headless --no-dkms

Like you said, this failed with a dkms module installation error.
./amdgpu-pro-install -y --opencl=pal --headless

I decided to ditch the "pro" script and try the amdgpu-install script with the no-dkms option.
./amdgpu-install -y --opencl=pal --headless --no-dkms

This worked on the 5.8 kernel. :)
Hey, thanks for the information. It will give me something to test when I get more GPUs in.

Also, (and I will edit my OP) if you are using a card older than the Vega, change --opencl=pal to opencl=legacy.
 
I guess this could be off topic but I've been using Ricks GPU utilities to set the power cap and control fan speed on my Radeon VII. I don't know of another linux utility that works for the Radeon VII.
 
Everything I've read says you want to stick to open source drivers if you're a gamer.

Correct me if I'm wrong but These drivers are mostly for legacy support, aren't they?
 
I guess this could be off topic but I've been using Ricks GPU utilities to set the power cap and control fan speed on my Radeon VII. I don't know of another linux utility that works for the Radeon VII.
Well <radio edit> I forgot the part to install radeon-profile. While I've not tested the power control, I use it to control the fan speeds, and those Vegas/VIIs need it. Instructions to get it are here. Just scroll down past the instructions to build it yourself, to the part where it's in a a repository. 3 commands and done. Now I have another edit for my OP thanks, and I really mean thanks. As I mentioned it's the first public guide I ever wrote and want it to be the best/most helpful it can be :)
 
Everything I've read says you want to stick to open source drivers if you're a gamer.

Correct me if I'm wrong but These drivers are mostly for legacy support, aren't they?
No, they are required by BOINC. Without them BOINC will not even recognize your GPU. As far as games, I can't really say. While I very strongly believe the open source community could, and does write much better drivers, there may well be other apps like BIONC that needs something specific from the proprietary driver.
 
No, they are required by BOINC. Without them BOINC will not even recognize your GPU. As far as games, I can't really say. While I very strongly believe the open source community could, and does write much better drivers, there may well be other apps like BIONC that needs something specific from the proprietary driver.
OpenCL libraries I believe
 
OpenCL libraries I believe
Again, no. BOINC will not detect the GPU without the driver. If you look in your coproc.xml you will see that openCL was detected but no matching components or some such.
 
Good info here. I will try to get around trying this at some point for my Radeon VII cards.
 
I decided to ditch the "pro" script and try the amdgpu-install script with the no-dkms option.
./amdgpu-install -y --opencl=pal --headless --no-dkms

The --headless option is a problem on linux Mint 20.1. It blacklisted amdgpu so I booted to a black screen. I removed the blacklist file, rebooted and reinstalled using:
sudo ./amdgpu-install -y --opencl=pal --no-dkms
 
Back
Top