How we got hardware acceleration of graphics to work in Ubuntu 18.04.2 with an Intel Core i7-9700K Coffee Lake processor

Intel Core I7.pngWe recently set up a new system using an Intel Core i7-9700K Coffee Lake processor, and discovered that the Intel® UHD Graphics 630 is not yet supported in Ubuntu, at least not in the 18.04 Long Term Support release. Therefore hardware acceleration of video did not work in Kodi or any other program. We first realized this when none of the VAAPI settings were shown in Kodi’s settings (they are normally found in Settings Player Settings Videos Processing).  Then we installed the vainfo program (using sudo apt install vainfo), and when we ran it we got this output:

libva info: VA-API version 1.1.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/
libva info: Found init function __vaDriverInit_1_1
libva error: /usr/lib/x86_64-linux-gnu/dri/ init failed
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit

Obviously this is not what you want to see, so we knew we had a problem.  Much additional research led us to the conclusion that the Intel Core i7-9700K processor is so new that it’s not yet supported in Ubuntu 18.04.

After searching many pages and sites, the answer appeared in a post by user yasij in the Kodi forum, although it seems he thought you’d need to start with Ubuntu 18.10 or 19.04 (the latter should have support for this processor built in, but it’s not a Long Term Support release).

What we found was that support for this processor could be added to Ubuntu 18.04.2 – note the point version here, you need at least the 4.18 Linux kernel in that version for this to work. Check your kernel version using uname -a if you aren’t sure.

The method is rather simple, actually. First you run this command to add the necessary repository:

sudo add-apt-repository ppa:mamarley/updates

Then you need to edit the file etc/apt/sources.list.d/mamarley-ubuntu-updates-bionic.list

nano etc/apt/sources.list.d/mamarley-ubuntu-updates-bionic.list
(Or use your preferred text editor).

Look for the line:
deb bionic main

and change bionic to cosmic:

deb cosmic main

Exit nano (Ctrl-X) and save your changes. Then run:
sudo apt update
sudo apt install i965-va-driver va-driver-all
sudo apt install libasound2 libasound2-plugins

The last two packages were needed to get sound to work in Kodi. We use ALSA audio, so if you use PulseAudio you may not need those, or you may need to upgrade different packages. Additional dependencies may be installed when you install or upgrade these packages.

Then either delete etc/apt/sources.list.d/mamarley-ubuntu-updates-bionic.list or comment out that repository (add # to the start of the line, like this):
# deb cosmic main

Then run:
sudo apt update
again so that no additional packages from that repository are inadvertently added.

Reboot the system.

Now when you run vainfo the output should look something like this (with no errors):

libva info: VA-API version 1.4.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/
libva info: Found init function __vaDriverInit_1_3
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.4 (libva 2.1.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Coffee Lake - 2.3.0
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Simple            :	VAEntrypointEncSlice
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSliceLP
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointEncSliceLP
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointEncSliceLP
      VAProfileH264MultiviewHigh      :	VAEntrypointVLD
      VAProfileH264MultiviewHigh      :	VAEntrypointEncSlice
      VAProfileH264StereoHigh         :	VAEntrypointVLD
      VAProfileH264StereoHigh         :	VAEntrypointEncSlice
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointEncPicture
      VAProfileVP8Version0_3          :	VAEntrypointVLD
      VAProfileVP8Version0_3          :	VAEntrypointEncSlice
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointEncSlice
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileHEVCMain10             :	VAEntrypointEncSlice
      VAProfileVP9Profile0            :	VAEntrypointVLD
      VAProfileVP9Profile0            :	VAEntrypointEncSlice
      VAProfileVP9Profile2            :	VAEntrypointVLD

Note that if you run vainfo in a ssh session, you will probably see one error message right at the beginning of the output:

error: can't connect to X server!

This is to be expected in a ssh session, but that error should not appear if you run vainfo from a terminal window on the desktop.

That should be all you need to do — at least it was all we needed to do to get support for this processor into Ubuntu 18.04.2. We hope it works for you, too!  Note that you are mixing packages intended for different versions of Ubuntu, so there’s always a chance that doing this might cause some unintended breakage somewhere, but so far we haven’t encountered any problems.