Score:1

Firefox refuse to use GPU hardware acceleration with Nvidia GPU. How to fix?

ph flag

Trying to turn on GPU acceleration in Firefox 115 snap.

Ubuntu 22.04.2 LTS

NVIDIA Corporation GP106 [GeForce GTX 1060 6GB]

NVIDIA Driver Version: 535.54.03

layers.acceleration.force-enabled = true

layers.offmainthreadcomposition.enabled = true (this key was missing, created it)

I restarted Firefox, rebooted system. To check if it works I started nvidia-smi dmon, played youtube and local h264.mp4 with Firefox to see if there is anything other than 0 in dec column of terminal output. When I play a video with VLC, it shows some % of decoding load with GPU, but Firefox refuse to use GPU. Any ideas how to fix it? Thank you!

UPDATE

Thanks to Raffa's answer, I've changed some other settings, here they are:

gfx.webrender.all false -> true
dom.webgpu.enabled false -> true
layers.gpu-process.enabled false -> true
layers.mlgpu.enabled add
media.gpu-process-decoder false -> true
media.ffmpeg.vaapi.enabled true (no change)

No success. Also tried the same tests with Chromium, no success. In Firefox about:support I have found a lot of failures, here are some of them:

WebGPU adapter by default "navigator.gpu.requestAdapter({})": { "not_supported": "WebGPU is not yet available in Release or Beta builds."

GPU_PROCESS Disabled by default = Enabled via layers.gpu-process.enabled = Blocked; error code FEATURE_FAILURE_DISABLED

WEBRENDER_COMPOSITOR Disabled by default = Cannot be enabled in release or beta = Blocked; error code FEATURE_FAILURE_DISABLE_RELEASE_OR_BETA

WEBGPU WebGPU cannot be enabled in release or beta = Blocked; error code WEBGPU_DISABLE_RELEASE_OR_BETA

HARDWARE_VIDEO_DECODING default = available ; user = force_enabled ; runtime = unavailable = Force disabled by gfxInfo = Blocked; error code FEATURE_FAILURE_VIDEO_DECODING_TEST_FAILED

Now i wonder, maybe i should try some alpha build?

UPDATE 2

So I have tried Firefox Nightly which is early alpha build. And yes, some failure strings from about:support gone, for example this one: WebGPU adapter by default "wgpuBackend": "Vulkan", "wgpuDevice": 7171, "wgpuDeviceType": "DiscreteGpu", "wgpuDriver": "NVIDIA", "wgpuDriverInfo": "535.54.03", "wgpuName": "NVIDIA GeForce GTX 1060 6GB", "wgpuVendor": 4318

But still HARDWARE_VIDEO_DECODING says Force disabled by gfxInfo ; FEATURE_FAILURE_VIDEO_DECODING_TEST_FAILED

After changing setting media.hardware-video-decoding.force-enabled = true and restarting Firefox Nightly i see in terminal output [GFX1-]: vaapitest: ERROR [GFX1-]: vaapitest: VA-API test failed: failed to initialise VAAPI connection.

So far what I found is that VA-API can not work with proprietary Nvidia drivers that I need to encode video with GPU (NVENC). It seems I have to stop here, hope someone will find a solution.

Raffa avatar
jp flag
Somewhat related and could help: https://askubuntu.com/a/1466268
Elven avatar
ph flag
Thank you very much, your link was quite useful
Score:0
ph flag

OK, finally I have found a solution. Some theory you can find here and here. In short: Firefox understand only VA-API HW acceleration. VA-API do not support Nvidia proprietary drivers. So we need a driver, that pretend to be VA-API but have NVDEC under its hood. Driver is here.

3 important things:

  1. I was unable to make Firefox stable to see this new driver. So I had to install unstable branch Firefox Nightly.

  2. It did not work on default EGL backend so I had to add NVD_BACKEND=direct to /etc/environment

  3. It's a bit tricky to make it understand VP9 codec that YouTube often use. So install that libgstreamer-plugins-bad1.0-dev before compiling or just install FF addon h264ify that will force YouTube to use good old h264 codec.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.