Varun Priolkar

How to use AMDGPU driver for Southern Islands and Sea Islands card on Ubuntu Linux

These instructions apply only for GCN 1.0/Southern Island cards and GCN 1.1/Sea Islands cards. You can check if your card falls in this categories here.

The AMDGPU driver is a newer driver for GNU/Linux and promises better performance and Vulkan support. You will need to do two steps to make it work.

  1. Userspace drivers – You need to get the latest Mesa and Xorg. You can do this by adding in the Padoka PPA, which contains the same. It is generally tested and then snapshotted so there are lesser chances of breakages. Also it is built on LLVM’s 4.0 branch, which offers faster shader compilation. For this just do sudo add-apt-repository ppa:paulo-miguel-dias/mesa -y, update the repositories with sudo apt-get update and install the needed package and update the packages with sudo apt-get install -y xserver-xorg-video-amdgpu && sudo apt-get -y upgrade. That’s it! Support for RADV Vulkan driver is enabled as well in this PPA.
  2. Kernel driver – You will need to compile support in for the AMDGPU driver for your card. For cards pre GCN 1.2 it is disabled by default at the time of writing this article. Experimental support for Southern Islands is only included post the 4.9.x series. You will also have to blacklist support for the default radeon driver.

Also make sure you are running Ubuntu 16.04 or Ubuntu 16.10.

Kernel driver

Compiling support in the kernel

This is not very hard. Firstly download the required packages. Run the command

RELATED  Backing up LXC containers with automation
sudo apt-get install -y git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc && sudo apt-get --no-install-recommends install -y kernel-package. Grab the latest mainline kernel from kernel.org. And then extract with cd Downloads && tar xvf linux-4.9.tar.xz command. Replace linux-4.9.tar.xz with the downloaded file. You can also verify if the download with PGP with instructions listed here. We’ll use the running kernel’s config as a base to compile the kernel with AMDGPU support. Run cd linux-4.9 && cp /boot/config-$(uname -r) .config. Then run make menuconfig  to change the config. Navigate to Device Drivers>Graphics support and press space to select Enable amdgpu support for SI/CIK parts.

You can customise a few other things in make menuconfig if you like

Clean the source tree and reset kernel parameters with make-kpkg clean  and then run fakeroot make-kpkg --initrd --revision=1.0.amdgpu kernel_image kernel_headers -j 9. Replace -j 9 with -j (no. of CPU cores + 1). After compilation is done, install with cd .. && sudo dpkg -i linux-headers-4.9.0_1.0.amdgpu_amd64.deb && sudo dpkg -i linux-image-4.9.0_1.0.amdgpu_amd64.deb. File names could be different. Replace appropriately.

If you are interested you can grab my build here. Support for SI and CIK cards is enabled.

Blacklisting radeon module

We will have to blacklist radeon kernel module to make sure AMDGPU kernel is selected. Do sudo nano /etc/default/grub to edit the bootloader config and add in modprobe.blacklist=radeon next to GRUB_CMDLINE_LINUX_DEFAULT line so that it looks like this GRUB_CMDLINE_LINUX_DEFAULT="quiet splash modprobe.blacklist=radeon". Then run

RELATED  Analysing Steam's network in India
sudo update-grub2  to update the bootloader entries. Now reboot!

lsmod | grep radeon shouldn’t show up any entries, while lsmod | grep amdgpu  should show something like this.

You can run vulkaninfo  command to verify that Vulkan is enabled as well.

Unity has some Vulkan demos that should work fine with the RADV Vulkan driver. They are experimental and so is RADV so YMMV. You can get them from a Google Plus post here. I couldn’t get them to work without crashing.

If I get some spare time I may set up a PPA and a script to build fresh kernels and auto upload to that. No promises tho! 🙂

22 Comments

  1. You’re awesome. I’ve been waiting for this guide for six months. There are a bunch of resources on the Arch Wiki and Gentoo and the like, but nothing specifically for Ubuntu. Thanks a ton for putting it together.

    • varunpriolkar

      Glad to know someone found it useful. 🙂

      >There are a bunch of resources on the Arch Wiki and Gentoo and the like, but nothing specifically for Ubuntu.
      That’s what I found to be the case too. You can try out the AMDGPU-PRO driver too if you are using Ubuntu 16.04.

  2. Is this possible to do on Ubuntu 14.04.5? I am using a DELL laptop with SI dedicated GPU and so far I have been unable to use it. And I am forced to stick to 14.

    • varunpriolkar

      Not easily, without potentially sacrificing the stability of your system. The SI GPU should be working on 14.04.5, albeit the performance/power management may not be as good.
      I would recommend you to try out the “LTS Enablement Stack” if you aren’t using that already: https://wiki.ubuntu.com/Kernel/LTSEnablementStack

      AMDGPU/AMDGPU-PRO would need you to update to Ubuntu 16.04 or Ubuntu 16.10 to try it out safely.

  3. This #step 1 so screwed my system, x does not load. Any help on restoring back to defaults? online suggestions dont work. Get (EE) Backtrace fault.

    • varunpriolkar

      I messed up. I put in a wrong PPA accidentally while writing that up. You need to remove the Xorg edgers PPA, which I accidentally put in the commands instead of the Padoka PPA.

      Do this:
      sudo apt-get install ppa-purge
      sudo ppa-purge ppa:xorg-edgers/ppa

      Let me know if that works for you. Again I am extremely sorry for messing up. I’ve updated the post.

  4. Worked for my r9 270x with kernel 4.10.0-rc7. I had to use dist-upgrade instead of upgrade.

  5. Do you have any experience using amdgpu with kvm+vfio? I can passthrough my AMD 7870 successfully to a Windows Guest and a Fedora 24 Guest (using standard radeon driver).
    I tried multiple distros / kernels, so far no luck. With a fresh 16.04, Padoka PPA and your kernel it boots with no errors and i can see in dmesg, lsmod and xorg.log that amdgpu get’s loaded but in the end Xorg complains:

    (EE) No devices detected.
    (EE) no screens found.

    and i’m stuck in console with blinking cursor. Any ideas how to track down the problem?

    • varunpriolkar

      It’s quite a coincidence that I was playing around with GPU passthrough these days. I tried passthroughing my card to a Linux guest on ESXI but it just wouldn’t start the radeon kernel driver even though I could see the card in lspci. It worked for Windows. I am yet to try KVM+VFIO.

      Amdgpu, especially for GCN 1.0 cards is still very young. I’d recommend you to try a 4.10.x kernel. Make sure you add the Padoka PPA and update too. But I’d say if it works on the radeon kernel driver and you are happy with the performance, there is no need to switch really. There is a reason why it is not enabled by default.

      Also try filing a bug here: https://bugzilla.kernel.org/. You may be asked to move it to the Xorg bug tracker. If you can, post it on Phoronix forums as well. There are many people working on the driver that visit there.

      • Hey, thanks for your quick reply. I finally got it to work with an Arch Linux guest. I also made a dist-upgrade on my Ubuntu host in between and i think qemu was one of the updated packages – i’m still on qemu 2.5 though, same as before – so maybe i was lucky with a bugfix for my specific problem.
        Anyways my current setup:

        Z77 Mainboard + i5 3570

        Ubuntu 16.04 Host with IGD Intel
        qemu 2.5 + ovmf + libvirt booting:

        Arch Linux 2017.02.01 with vfio’ed AMD 7870 GPU

        Arch kernel (currently 4.9.8) has amdgpu CIK/SI support enabled per default and after a standard gnome install xorg starts just fine with the amdgpu driver (don’t forget to blacklist radeon and add amdgpu to initramfs, as described in the Arch Wiki amdgpu article). I’ll probably try to install amdgpu-pro on top of it at some point.

        Looks like Arch Linux in general is by far the best option for these kind of things.

        So best of luck for your progress. Although i never tried ESXi, i have the feeling that KVM + VFIO will be the better choice in the long run for many reasons.

        • varunpriolkar

          Excellent! I am on Arch as well now. Still deciding on a GPU(need displayport) for the host. I’ll just passthrough my more powerful R9 280(7950) for the Windows guest and use Windows guest on one monitor and Arch Linux host on the other.

          I’m curious on why you are running Linux on a VM with passthrough. Could have just used the guest. BTW there is an excellent application called Synergy to sync keyboard/mouse between systems.

          Also can I email you on your provided mail id? I’d really like to know more about how you got it all to work incase I get stuck somewhere. I had tried KVM on Proxmox earlier but it all went awfully wrong after an update which made my system unbootable.

  6. I compiled the kernel like you said, but couldn’t install it. Could you please help?

    user@notebook:~/k$ sudo dpkg -i linux-headers-4.9.13_1.0.amdgpu_amd64.deb
    Selecting previously unselected package linux-headers-4.9.13.
    (Reading database … 282292 files and directories currently installed.)
    Preparing to unpack linux-headers-4.9.13_1.0.amdgpu_amd64.deb …
    Unpacking linux-headers-4.9.13 (1.0.amdgpu) …
    Setting up linux-headers-4.9.13 (1.0.amdgpu) …
    Examining /etc/kernel/header_postinst.d.
    run-parts: executing /etc/kernel/header_postinst.d/dkms 4.9.13 /boot/vmlinuz-4.9.13
    Error! echo
    Your kernel headers for kernel 4.9.13 cannot be found at
    /lib/modules/4.9.13/build or /lib/modules/4.9.13/source.

    • varunpriolkar

      9th March 2017 at 1:34 am

      That’s quite strange. Not sure why you are hitting the issue. Are you using any DKMS modules? Make sure you have the kernel headers installed for the kernel you are running just in case. Also you can maybe try my precompiled kernel.

      I’m extremely sorry for the late reply. Was caught up with work.

      • It’s ok, thanks anyway. I did resolve it straight way: just created a symlink at /lib/modules/4.9.13/build, taken it from /lib/modules/4.9.13-040913-generic/build. I had also installed a kernel from kernel.ubuntu.com.

        But the sad part is, that it didn’t help to get my Radeon HD 8750M any faster. glmark2 shows same 480 score, regardless what kernel I boot. And Vulkan tests were not so smooth also on half resolution and not detailed mode.

        There was something interesting, I think you should know about it. As you said, I copied .config from v4.9.13 Kernel, taken from Ubuntu site. And as I run menuconfig and navigated to Device Drivers>Graphics support, I saw, that “amdgpu support for SI parts” was already enabled. For “CIK Parts” was disabled.
        Do I understand it right, that support for “Southern Islands” chipset, i.e. for my HD 8750M is already in mainline for kernel 4.9.13 and I don’t need to compile it self?

  7. And yes, I have DKMS modules, if it matters – virtualbox’s modules.
    Headers were installed, but from 4.9.13-040913-generic package.

  8. I’d like to note that compilation on Ubuntu with the make-kpkg command fails under kernels > 4.9. This is due to kernel developers removing the “REPORTING-BUGS” file from the source tree. If you want to continue using make-kpkg, copy the file from the 4.9 tree to your kernel source.

  9. Thanks for the guide – it got me running amdgpu on kernel 4.9.11 in 16.04.2 earlier.
    However, in an update to 4.9.21, things seem to have been broken.

    Performance has dropped substantially, and booting 4.9.11 instead doesn’t change anything.

    I did get an error about missing firmware for Tonga and Topaz cards when installing 4.9.21 but ignored it as my card is an r9 270x.

    Do you have any advice? Thanks

  10. Hi Varun,

    Thanks for the great guide. I think on Ubuntu 17.04 support for SI and CIK cards is enabled by default in the kernel, so the only step required in 17.04 is to blacklist the radeon module.

  11. Im trying to build the kernel, but i can’t get the headers.deb.

  12. i managed to build and install but after reboot i get black screen with blinking cursor.
    any help

Leave a Reply