Intel Graphics - Best practices and settings for hardware acceleration?

Getting hardware acceleration on Linux for Intel graphics has taken a little fiddling as the defaults are geared towards maximum stability as opposed to performance, even on newer hardware where support has improved in the kernel and related packages.

I’ve been trying to document steps to take when installing Fedora for the first time on newer hardware (e.g. Intel gen11+ like my Thinkpad X1 Carbon Gen 9 with Iris Xe graphics) and wanted to get the community’s thoughts on them:

:warning: The below is a work in progress


1. Install RPMFusion repos

sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
sudo dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm

2. Install multimedia packages & Intel tools

sudo dnf groupinstall multimedia
sudo dnf install intel-media-driver libva libva-utils gstreamer1-vaapi ffmpeg intel-gpu-tools mesa-dri-drivers mpv

3. Add environment variable for Libva

Add the following line to your .bashrc (if using bash):

export LIBVA_DRIVER_NAME=iHD

4. Enable Intel GuC and HuC and Framebuffer compression

GuC and HuC are features built into newer-gen Intel graphics and apparently have power usage and performance benefits.

Add kernel parameters to load GuC and HuC (contrary to popular belief, they are not enabled by default except on Intel gen12+ platforms in the kernel) by entering the following:

sudo nano /etc/modprobe.d/i915.conf

and paste the following into it:

options i915 enable_guc=3
options i915 enable_fbc=1

Then rebuild your intramfs with the following:

sudo dracut --force

Then reboot (important)

5. Test to make sure everything is enabled and working properly

  1. Test VA-API support with vainfo and compare against this ArchWiki section
  2. Check to make sure GuC and HuC are enabled:
sudo dmesg | grep guc 

Should return something like GuC firmware i915/tgl_guc_62.0.0.bin version 62.0 submission:enabled

sudo dmesg | grep huc 

Should return something like HuC firmware i915/tgl_huc_7.9.3.bin version 7.9 authenticated:yes

  1. Test VA-API support:
    1. Download a test video file
    2. Open a new terminal window and run sudo intel_gpu_top (keep this window open)
    3. In a separate terminal window, run mpv --hwdec=auto <video file>
    4. Go back to the intel_gpu_top terminal window and check to make sure the “Video” bar shows activity, this indicates that video is being accelerated properly.

6. Hardware acceleration in browsers

For the time being, both Chrome/Chromium and FIrefox have issues with hardware acceleration in the most recent versions of their browsers (Chrome/Chromium 100 and Firefox 98) with Wayland. Hopefully future versions will support VA-API again soon.


Any thoughts on the above? Looking for any suggestions regarding packages to install, any optimizations I missed, etc.

One thing that still bugs me is that the VideoEnhance engine in intel_gpu_top still shows no activity even when playing an accelerated video. Not clear why that is but if anyone else has got that working, let me know and I can add those steps.

6 Likes

In Firefox, under Settings->Performance, do you see this option?

2017-08-27-03-46-52-fd0019

1 Like

Here’s the Fedora doc for enabling hardware acceleration in Firefox:

https://fedoraproject.org/wiki/Firefox_Hardware_acceleration#Video_decoding_on_Intel

2 Likes

Hi, yes that “Use hardware acceleration when available” is selected and I’ve been through both the Fedora docs and the Archwiki docs on both hardware acceleration in general and Firefox and Chrome/Chromium specifically.

With Firefox, the RDD sandbox currently breaks video decode acceleration (2d canvas acceleration seems to be fine however) and it 's a known issue in their bug tracker so hopefully it will improve in the next major release as there’s activity to resolve it in the latest Nightlies.

In Wayland there are greater issues with video acceleration but there’s activity taking place on the part of Intel and others to improve support (e.g. this pull request submitted by an Intel dev last month)

It also seems that gen12+ graphics and up (Tiger Lake and newer) are now going to see features incorporated through oneVPL, part of Intel’s larger new oneAPI framework that has replaced MediaSDK going forward.

Essentially, the sands are shifting quite a bit at multiple levels and the rest of the stack above hasn’t caught up yet. Even though Tiger Lake isn’t exactly brand new, it’s not fully supported yet with most applications since there’s plenty of work to be done to update higher-level frameworks like FFMPEG (I think gstreamer supports oneVPL now but not 100% sure)

That’s my interpretation of everything I’ve read so far though :slight_smile:

1 Like

Got it. Unfortunately, it seems I won’t be able to troubleshoot this more for you since all my stuff is AMD/Radeon at this point, but I’m sure there are others around here with newer Intel GPUs.

1 Like

What a great post. Thank you for creating this. Very nice details. I wish Fedora devs had created a post on these issues in their FedoraMagaine blog (something like 5 things to do after installing Fedora 35 for better graphics in Intel-based laptop).

(@inslee If users are allowed to post a blog then I think it’s a good idea to make a blog post about this. It will definitely help newcomers like me.)

After reading the output of dnf info gstreamer1-vaapi, I quickly installed that package. I wonder how I missed this package from installation!

Installed Libva a long time ago. But is it necessary to install libva-utils? According to dnf info statement, it says, “libva-utils package contains tools that are provided as part of libva, including the vainfo tool for determining what (if any) libva support is available on a system.

Let’s say, I install that use package. How do I use this package to know, “if any libva support is available” on my system? Is there any command that libva-utils provide?!

Similar doubts about this package igt-gpu-tools (aka, intel-gpu-tools)? Why do we need this tool!?
Please, do let me know. I want to improve Fedora 35 experience if is any places to improve upon.

2 Likes

You can use vainfo command to see various information about libva on your system. To see which files libva-utils package contains, you can use rpm -ql libva-utils command.

1 Like

When I run vainfo, I get this

  ⟹  vainfo
libva info: VA-API version 1.13.0
libva info: Trying to open /usr/lib64/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_13
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.13 (libva 2.13.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 21.4.3 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileNone                   :	VAEntrypointStats
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Simple            :	VAEntrypointEncSlice
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointFEI
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointFEI
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:	VAEntrypointFEI
      VAProfileVP8Version0_3          :	VAEntrypointVLD

When I run the test you mentioned and another test that I found, I get to see some warnings/errors. But the video bar, shows activity, which means the video is being accelerated, so why I’m getting warnings!

Test 1

 ⟹  mpv --hwdec=auto aa.mp4
 (+) Video --vid=1 (*) (h264 1280x720 30.000fps)
File tags:
 Artist: Blender Foundation 2008, Janus Bager Kristensen 2013
 Comment: Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
 Composer: Sacha Goedegebure
 Genre: Animation
 Title: Big Buck Bunny, Sunflower version
[vo/gpu/wayland] GNOME's wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
[ffmpeg] AVHWDeviceContext: Failed to query surface attributes: 20 (the requested function is not implemented).
[vo/gpu/vaapi-egl] failed to retrieve libavutil frame constraints
Cannot load libcuda.so.1
Using hardware decoding (vaapi).
VO: [gpu] 1280x720 vaapi[nv12]
V: 00:00:09 / 00:00:10 (100%)

Exiting... (End of file)

Test 2

  ⟹  vlc -v --ffmpeg-hw aa.mp4
VLC media player 3.0.17.2 Vetinari (revision )
Warning: option --ffmpeg-hw no longer exists.
[000055a7bd791b70] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
[00007f8940001170] mp4 demux warning: elst box found
[00007f8940001170] mp4 demux warning: STTS table of 1 entries
[00007f8940001170] mp4 demux warning: CTTS table of 206 entries
[00007f8930005720] gl gl: Initialized libplacebo v4.157.0 (API v157)
libva info: VA-API version 1.13.0
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[00007f8930005720] glconv_vaapi_x11 gl error: vaInitialize: unknown libva error
libva info: VA-API version 1.13.0
libva info: Trying to open /usr/lib64/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_13
libva info: va_openDriver() returns 0
[00007f8940c042d0] avcodec decoder: Using Intel iHD driver for Intel(R) Gen Graphics - 21.4.3 () for hardware decoding
[h264 @ 0x7f8940c39c80] Using deprecated struct vaapi_context in decode.
[00007f8938121900] qt window warning: orphaned video window
QObject::~QObject: Timers cannot be stopped from another thread

Errors like:

  • libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
  • glconv_vaapi_x11 gl error: vaInitialize: unknown libva error
  • [00007f3f54001170] mp4 demux warning: elst box found
  • [00007f3f54001170] mp4 demux warning: STTS table of 1 entries
  • [00007f3f54001170] mp4 demux warning: CTTS table of 206 entries

Is this normal?!

1 Like

Your vainfo output and activity on the video bar indicates that hardware video decoding works fine. Those warnings look like debug messages and it will be fine unless you have problems during video playback.

1 Like

The best way I’ve found to test is to run sudo intel_gpu_top and monitor the Video bar to see if it shows activity when playing back videos. If it does, that means hardware decoding is working properly. Not sure about the errors but I wouldn’t worry about them too much. For VLC, the driver_name = (null) line makes me think that you haven’t set the LIBVA_DRIVER_NAME=iHD environment variable.

What is interesting however is that the VideoEnhance engine (underneath the Video bar in intel_gpu_top shows no activity for me even when playing a video. I’m still doing some digging but my hypotheses are as follows:

  • Intel is sunsetting Intel Media SDK which was an API for applications to leverage hardware acceleration and replacing it with oneVPL, part of their oneAPI initiative intended to help streamline development of software that leverages Intel-specific features.
  • All video decode/transcode/encode improvements and enhancements that will take advantage of Tiger Lake and above processors will be implemented in oneVPL, not Intel Media SDK and any higher-level multimedia frameworks like FFMPEG and GStreamer will need to be built with oneVPL instead of Intel Media SDK for those frameworks to take advantage of Tiger Lake and above’s capabilities.
  • In Fedora 35 (not sure about 36), FFMPEG is still being built with Intel Media SDK so it won’t be using oneVPL and the instructions for building FFMPEG with oneVPL are still forthcoming

The parts where some of my hypotheses fall through are the following:

  • Prior to moving to Fedora a few weeks back, I was running Arch with X11 on the same laptop and I believe both Video and VideoEnhance engines were being utilized when playing back video using MPV.
  • This would mean that FFMPEG may not require being built with oneVPL in order to utilize both acceleration engines on Tiger Lake and later processors and that it might have been intel_media_driver (which sits beneath Intel Media SDK/oneVPL) handling the offloading to the hardware properly.
  • Fedora uses Wayland instead of X11 and until this pull request is merged and released in RPMFusion, I can’t be sure if that is the reason why only Video is being engaged during video decoding currently.

I’m hoping that once FFMPEG with oneVPL support (which seems to be in progress but I’m not clear which version of FFMPEG will have it by default) and that intel-media-driver PR are merged, we’ll see better utilization of the capabilities of these graphics when it comes to video. Fingers crossed.

Sidenote: I have no idea what the Blitter engine in intel_gpu_top is for but it definitely doesn’t do anything on Linux. Never seen any activity on it on X11 or Wayland at all.

2 Likes

An update:

I upgraded to Fedora 36 beta yesterday which comes with a number of upgrades to the underlying hardware acceleration stack. intel-media-driver, gstreamer, oneVPL, and more all show updated packages in F36.

Now when I play videos with Totem (the built-in video player called Videos that runs on top of gstreamer), both Video AND VideoEnhance are activated!

This is what tells me that hardware acceleration is finally taking advantage of the hardware.

MPV and VLC still only use the Video engine so there are updates that need to still be made to FFMPEG and VLC (and browsers in general) but it looks like gstreamer is the most mature option for gen12+ graphics so far.

One interesting thing to note: Gnome Web, the web browser formerly called Epiphany, was touted to have full hardware acceleration support in Gnome 42 as well but it continues to have a glitch where videos are green and contain corrupted info from the GPU. I believe Gnome Web is also backed by gstreamer so I’m not sure why acceleration works in Videos but not Web.

3 Likes

Is there any meaningful advantage in doing this for older CPU’s? Like 5th gen i7?

These steps are just to make sure that you are using your laptop hardware at full throttle, every inch of it from every corner. (if that make sense)

That’s a very good documentation of the process.

One note still, I would like to update.
There should be no need to “hardcode” the driver to iHD. it should be autodetected automatically and iHD (intel-media-driver) should be choosen by default as soon as the correct hardware is used.
(there is a previous bug in early fc35 that because of the switch to iris, some card didn’t used the appropriate driver, but it’s now fixed upstream.

The long term is that if there is an even better driver for some hw, having iHD hardcoded on end-users system will block them from using the more appropriate driver.

Thank in advance to remove this mention.

That’s good to know that it was fixed upstream. Unfortunately I can’t edit the original post anymore though, I think edits can only be made within a certain timeframe after posting.

I believe that’s based on your user level. At the next level up, you can edit for up to one month:

1 Like

It seesm atleast on my hardware (10th gen intel) this part is not working:

options i915 enable_guc=3

after reboot when I check the dmesg i get this:

[    2.084958] Setting dangerous option enable_guc - tainting kernel
[    2.085550] i915 0000:00:02.0: [drm] Incompatible option enable_guc=3 - GuC submission is N/A
[    2.180501] i915 0000:00:02.0: [drm] GuC firmware i915/kbl_guc_62.0.0.bin version 62.0 submission:disabled
1 Like

welcome to ask :fedora:

The first line that tells you it is tainting kernel is related to secure boot and an out-of-tree module.
The second line says that option is incompatible. What is it supposed to do? Have you checked the available and functional modes that do work? Do you need that option? Most have no issues with the intel IGP and drivers.

Please provide a bit more info about the video. inxi -Fzx will assist us, as will lsmod | grep i915

1 Like