AMD proprietary graphics drivers on Ubuntu 23.04

Page content

Somewhat recently I was reading about x265 (High Efficiency Video Coding (HEVC)) and noticed it had quite some (space) advantages over its predecessor x264 (Advanced Video Coding (AVC)). I have a large family video collection (which keeps growing) and thought I might save some space and bandwidth, by converting them from 264 to 265. Reading up on my GPU ( 6600 XT ) specifications, it should support hardware encoding! Then my time got consumed by other projects, until…

issues arise

redshift and gamma

Only a couple of weeks ago, I started noticing that my eyeballs were hurting in the evening. I was staying up a bit later than usual and the monitor was shining brightly into the night. Then I noticed it and it hit me. redshift was not running anymore! After trying to run redshift manually (which failed), I also tried adjusting the gamma with xgamma, which also did not work. :-(

codeweavers and hearthstone

When I tried running HearthStone, the in-game menu was OK, but as soon as I tried to play, the performance was horrible and unacceptable. This is weird, since I was used to this working completely fine. Especially since it can even run on my phone.

P.S. Full disclosure, I’m a BetterTester at CodeWeavers. If you want to buy CrossOver please use my affiliate link

handbrake and AMD VCN

Having graphics issues, it reminded me of the encoding project I was looking into. The tool of choice (for me) to (re)encode videos is HandBrake. They have a section in their documentation about AMD’s VCN. Apparently I need the proprietary drivers for that as well :-(

the solution for all

AMD’s proprietary Linux Radeon drivers can be easily found on their website. Currently the version is 23.10.2, but they ‘only’ support Ubuntu 20.04.5 HWE and Ubuntu 22.04.2 and I am running 23.04. Yes, I like to live on the edge (a little bit).

AMDs package

Installing the package is easy (after downloading it):

root@host:~# dpkg -i amdgpu-install_5.4.50401-1_all.deb

If you’re curious about the files inside of this deb, let me enlighten you:

/etc/amdgpu-install/amdgpu-setup.conf
/etc/apt/preferences.d/repo-radeon-pin-600
/etc/apt/sources.list.d/amdgpu.list
/etc/apt/sources.list.d/rocm.list
/etc/apt/trusted.gpg.d/rocm-keyring.gpg
/usr/bin/amdgpu-install
/usr/bin/amdgpu-setup
/usr/share/amdgpu-install/AMDGPUPROEULA
/usr/share/amdgpu-install/amdgpu.list.template
/usr/share/amdgpu-install/orig/amdgpu.list
/usr/share/amdgpu-install/orig/rocm.list
/usr/share/amdgpu-install/rocm.list.template
/usr/share/doc/amdgpu-install
/usr/share/doc/amdgpu-install/changelog.Debian.gz
/usr/share/doc/amdgpu-install/copyright

add jammy repository and kernel

AMDs kernel modules depend on the Ubuntu 22.04 kernel and that specific kernel version. So I added the jammy repository (so I can access the kernel packages easily). For that, I created /etc/apt/sources.list.d/jammy.list with the following content:

# need to install the old kernel for amdgpu drivers
deb http://nl.archive.ubuntu.com/ubuntu jammy main restricted
deb http://nl.archive.ubuntu.com/ubuntu jammy-updates main restricted

Now the the Ubuntu 22.04 kernel can be installed easily:

root@host:~# apt-get update
root@host:~# apt-get install linux-headers-5.19.0-46-generic linux-image-5.19.0-46-generic linux-modules-5.19.0-46-generic linux-modules-extra-5.19.0-46-generic

install amdgpu

Can not remember exactly how I installed the packages, by I think it was something like this:

root@host:~# apt-get install amdgpu-dkms

The installation failed. Expected something like this might happen, as I am using Ubuntu Jammy 22.04.2 repositories on a Ubuntu Lunar 23.04 system. Retrying the failed installation, gave me the following output:

root@host:~# apt-get -f install
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up amdgpu-dkms (1:6.0.5.50502-1607507.22.04) ...
Removing old amdgpu-6.0.5-1607507.22.04 DKMS files...
Module amdgpu-6.0.5-1607507.22.04 for kernel 5.19.0-46-generic (x86_64).
Before uninstall, this module version was ACTIVE on this kernel.

amdgpu.ko:
 - Uninstallation
   - Deleting from: /lib/modules/5.19.0-46-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

amdttm.ko:
 - Uninstallation
   - Deleting from: /lib/modules/5.19.0-46-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

amdkcl.ko:
 - Uninstallation
   - Deleting from: /lib/modules/5.19.0-46-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

amd-sched.ko:
 - Uninstallation
   - Deleting from: /lib/modules/5.19.0-46-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

amddrm_ttm_helper.ko:
 - Uninstallation
   - Deleting from: /lib/modules/5.19.0-46-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

amddrm_buddy.ko:
 - Uninstallation
   - Deleting from: /lib/modules/5.19.0-46-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.
depmod...
Deleting module amdgpu-6.0.5-1607507.22.04 completely from the DKMS tree.
Loading new amdgpu-6.0.5-1607507.22.04 DKMS files...
Building for 5.19.0-46-generic 6.2.0-25-generic
Building for architecture x86_64
Building initial module for 5.19.0-46-generic
Done.
Forcing installation of amdgpu

amdgpu.ko:
Running module version sanity check.
 - Original module
 - Installation
   - Installing to /lib/modules/5.19.0-46-generic/updates/dkms/

amdttm.ko:
Running module version sanity check.
 - Original module
 - Installation
   - Installing to /lib/modules/5.19.0-46-generic/updates/dkms/

amdkcl.ko:
Running module version sanity check.
 - Original module
 - Installation
   - Installing to /lib/modules/5.19.0-46-generic/updates/dkms/

amd-sched.ko:
Running module version sanity check.
 - Original module
 - Installation
   - Installing to /lib/modules/5.19.0-46-generic/updates/dkms/

amddrm_ttm_helper.ko:
Running module version sanity check.
 - Original module
 - Installation
   - Installing to /lib/modules/5.19.0-46-generic/updates/dkms/

amddrm_buddy.ko:
Running module version sanity check.
 - Original module
 - Installation
   - Installing to /lib/modules/5.19.0-46-generic/updates/dkms/
depmod...
Building initial module for 6.2.0-25-generic
ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/amdgpu-dkms.0.crash'
Error! Bad return status for module build on kernel: 6.2.0-25-generic (x86_64)
Consult /var/lib/dkms/amdgpu/6.0.5-1607507.22.04/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
dpkg: dependency problems prevent configuration of amdgpu:
 amdgpu depends on amdgpu-dkms; however:
  Package amdgpu-dkms is not configured yet.

dpkg: error processing package amdgpu (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
																										  Errors were encountered while processing:
 amdgpu-dkms
 amdgpu
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

So the kernel module compilation is broken, because it also tries to compile for the 6.0.x kernel (which ships with 23.04). Luckily I have some old tricks up my sleeve. This can be solved by modifying 1 line of code in /usr/lib/dkms/common.postinst. Change this:

for kernel in /boot/config-*; do

and replace it with this:

for kernel in /boot/config-5*; do

And watch the installation finishing successfully:

root@host:~# apt-get -f install
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up amdgpu-dkms (1:6.0.5.50502-1607507.22.04) ...
Removing old amdgpu-6.0.5-1607507.22.04 DKMS files...
Module amdgpu-6.0.5-1607507.22.04 for kernel 5.19.0-46-generic (x86_64).
Before uninstall, this module version was ACTIVE on this kernel.

amdgpu.ko:
 - Uninstallation
   - Deleting from: /lib/modules/5.19.0-46-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

amdttm.ko:
 - Uninstallation
   - Deleting from: /lib/modules/5.19.0-46-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

amdkcl.ko:
 - Uninstallation
   - Deleting from: /lib/modules/5.19.0-46-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

amd-sched.ko:
 - Uninstallation
   - Deleting from: /lib/modules/5.19.0-46-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

amddrm_ttm_helper.ko:
 - Uninstallation
   - Deleting from: /lib/modules/5.19.0-46-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

amddrm_buddy.ko:
 - Uninstallation
   - Deleting from: /lib/modules/5.19.0-46-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.
depmod...
Deleting module amdgpu-6.0.5-1607507.22.04 completely from the DKMS tree.
Loading new amdgpu-6.0.5-1607507.22.04 DKMS files...
Building for 5.19.0-46-generic
Building for architecture x86_64
Building initial module for 5.19.0-46-generic
Done.
Forcing installation of amdgpu

amdgpu.ko:
Running module version sanity check.
 - Original module
 - Installation
   - Installing to /lib/modules/5.19.0-46-generic/updates/dkms/

amdttm.ko:
Running module version sanity check.
 - Original module
 - Installation
   - Installing to /lib/modules/5.19.0-46-generic/updates/dkms/

amdkcl.ko:
Running module version sanity check.
 - Original module
 - Installation
   - Installing to /lib/modules/5.19.0-46-generic/updates/dkms/

amd-sched.ko:
Running module version sanity check.
 - Original module
 - Installation
   - Installing to /lib/modules/5.19.0-46-generic/updates/dkms/

amddrm_ttm_helper.ko:
Running module version sanity check.
 - Original module
 - Installation
   - Installing to /lib/modules/5.19.0-46-generic/updates/dkms/

amddrm_buddy.ko:
Running module version sanity check.
 - Original module
 - Installation
   - Installing to /lib/modules/5.19.0-46-generic/updates/dkms/
depmod...
update-initramfs: Generating /boot/initrd.img-5.19.0-46-generic

Setting up amdgpu (1:5.5.50502-1607507.22.04) ...
Scanning processes...
Scanning processor microcode...
Scanning linux images...

Failed to check for processor microcode upgrades.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

Reboot, select the older kernel and you will be good to go!

Addendum 1: updating

During updating, I got errors from DKMS, because it was still trying to build the module for the newer kernels:

Processing triggers for linux-image-6.2.0-26-generic (6.2.0-26.26) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 6.2.0-26-generic
Sign command: /usr/bin/kmodsign
Signing key: /var/lib/shim-signed/mok/MOK.priv
Public certificate (MOK): /var/lib/shim-signed/mok/MOK.der

Running the pre_build script:
checking for a BSD-compatible install... /usr/bin/install -c
checking for gcc... x86_64-linux-gnu-gcc-12
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether x86_64-linux-gnu-gcc-12 accepts -g... yes
checking for x86_64-linux-gnu-gcc-12 option to enable C11 features... none needed
checking how to run the C preprocessor... x86_64-linux-gnu-gcc-12 -E
checking kernel source directory... /usr/src/linux-headers-6.2.0-26-generic
checking kernel build directory... /usr/src/linux-headers-6.2.0-26-generic
checking kernel source version... 6.2.0-26-generic
checking kernel file name for module symbols... Module.symvers
checking for linux/overflow.h... yes
checking for linux/sched/mm.h... yes
checking for linux/sched/task.h... yes
checking for linux/sched/signal.h... yes
checking for linux/nospec.h... yes
checking for linux/bits.h... yes
checking for linux/io-64-nonatomic-lo-hi.h... yes
checking for asm/set_memory.h... yes
checking for asm/fpu/api.h... yes
checking for uapi/linux/sched/types.h... yes
checking for linux/compiler_attributes.h... yes
checking for linux/dma-fence.h... yes
checking for linux/dma-resv.h... yes
checking for linux/mmap_lock.h... yes
checking for linux/pci-p2pdma.h... yes
checking for linux/dma-attrs.h... no
checking for linux/mem_encrypt.h... yes
checking for linux/dma-buf-map.h... no
checking for linux/iosys-map.h... yes
checking for linux/stdarg.h... yes
checking for linux/dma-fence-chain.h... yes
checking for linux/xarray.h... yes
checking for linux/container_of.h... yes
checking for linux/cc_platform.h... yes
checking for linux/processor.h... yes
checking for linux/dma-map-ops.h... yes
checking for drm/drm_backport.h... no
checking for drm/amdgpu_pciid.h... no
checking for drm/drm_auth.h... yes
checking for drm/drm_irq.h... no
checking for drm/drm_connector.h... yes
checking for drm/drm_encoder.h... yes
checking for drm/drm_plane.h... yes
checking for drm/drm_print.h... yes
checking for drm/drm_drv.h... yes
checking for drm/drm_file.h... yes
checking for drm/drm_debugfs.h... yes
checking for drm/drm_ioctl.h... yes
checking for drm/drm_vblank.h... yes
checking for drm/drm_device.h... yes
checking for drm/drm_gem_framebuffer_helper.h... yes
checking for drm/drm_audio_component.h... yes
checking for drm/drm_util.h... yes
checking for drm/drm_atomic_uapi.h... yes
checking for drm/drm_probe_helper.h... yes
checking for drm/drmP.h... no
checking for drm/task_barrier.h... yes
checking for drm/drm_managed.h... yes
checking for drm/amd_asic_type.h... yes
checking for drm/drm_aperture.h... yes
checking for drm/dp/drm_dp_helper.h... no
checking for drm/dp/drm_dp_mst_helper.h... no
checking for drm/display/drm_dp_helper.h... yes
checking for drm/display/drm_dp_mst_helper.h... yes
checking for drm/display/drm_dsc.h... yes
checking for drm/display/drm_dsc_helper.h... yes
checking for drm/display/drm_hdmi_helper.h... yes
checking for drm/display/drm_hdcp_helper.h... yes
checking for drm/display/drm_hdcp.h... yes
checking for drm/display/drm_dp.h... yes
checking for drm/drm_dsc.h... no
checking for drm/drm_dsc.h... (cached) no
checking for linux/pgtable.h... yes
checking for drm/drm_simple_kms_helper.h... yes
checking for drm/drm_buddy.h... yes
checking for drm/drm_framebuffer.h... yes
checking for drm/drm_blend.h... yes
checking for drm/drm_damage_helper.h... yes
checking for nproc... yes
checking for supported chips... done
checking for nproc... (cached) yes
checking for module configuration... done
configure: creating ./config.status
config.status: creating config/config.h

Building module:
Cleaning build area...(bad exit status: 2)
make -j16 KERNELRELEASE=6.2.0-26-generic TTM_NAME=amdttm SCHED_NAME=amd-sched -C /lib/modules/6.2.0-26-generic/build M=/var/lib/dkms/amdgpu/6.0.5-1607507.22.04/build....(bad exit status: 2)
ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/amdgpu-dkms.0.crash'
Error! Bad return status for module build on kernel: 6.2.0-26-generic (x86_64)
Consult /var/lib/dkms/amdgpu/6.0.5-1607507.22.04/build/make.log for more information.

dkms autoinstall on 6.2.0-26-generic/x86_64 failed for amdgpu(10)
Error! One or more modules failed to install during autoinstall.
Refer to previous errors for more information.
   ...fail!
run-parts: /etc/kernel/postinst.d/dkms exited with return code 11
dpkg: error processing package linux-image-6.2.0-26-generic (--configure):
 installed linux-image-6.2.0-26-generic package post-installation script subprocess returned error exit status 1
No apport report written because MaxReports is reached already
															  Errors were encountered while processing:
 linux-headers-6.2.0-26-generic
 linux-headers-generic
 linux-generic
 linux-image-6.2.0-26-generic
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

I looked through the dkms man-page and lots of configuration bits, but could not figure it out. Then I thought to ask by creating an issue on github and promply received the correct fix from xuzhen.

The trick is to modify the dkms configuration provided by AMD and add the following line to /usr/src/amdgpu-6.0.5-1607507.22.04/dkms.conf :

BUILD_EXCLUSIVE_KERNEL="^5.*"

Addendum 2: tear free

And if you want to ensure “Tear Free” is forcefully enabled (not set to automatic), you can check the current state with:

user@host:~$ xrandr -q --verbose | grep -A1 TearFree
	TearFree: auto
			supported: off, on, auto

To force TearFree on, you can use xrandr again:

user@host:~$ xrandr --output DisplayPort-1 --set TearFree on