How To Get Flatpak Apps And Games Built With OpenGL To Work With Proprietary Nvidia Graphics Drivers

Flatpak

Some applications and games built with OpenGL support and packaged as Flatpak fail to start with proprietary Nvidia drivers. This article explains how to get such Flatpak applications or games them to start, without installing the open source drivers (Nouveau).

Here's an example. I'm using the proprietary Nvidia drivers on my Ubuntu 18.04 desktop (nvidia-driver-390) and when I try to launch the latest Krita 4.1 installed as Flatpak (which is built with OpenGL support), the following errors are displayed:

$ /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=krita --file-forwarding org.kde.krita
Gtk-Message: Failed to load module "canberra-gtk-module"
Gtk-Message: Failed to load module "canberra-gtk-module"
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
Could not initialize GLX

Winepak games (Windows games bundled with Wine as Flatpak packages) also seem affected by this Flatpak issue, which is still open since 2016.

To fix Flatpak games and applications not starting when using OpenGL with proprietary Nvidia graphics drivers, you'll need to install a runtime for your currently installed proprietary Nvidia drivers. Here's how to do this.

1. Add the FlatHub repository if you haven't already. You can find exact instructions for your Linux distribution here.

2. Now you'll need to figure out the exact version of the proprietary Nvidia drivers installed on your system. 

This step is dependant of the Linux distribution you're using and I can't cover all cases. The instructions below are Ubuntu-oriented (and Ubuntu flavors) but hopefully you can figure out for yourself the Nvidia drivers version installed on your system.

To do this in Ubuntu, open Software & Updates, switch to the Additional Drivers tab and note the name of the Nvidia driver package.

As an example, this is nvidia-driver-390 in my case, as you can see here:

Additional drivers tab nvidia proprietary Ubuntu

That's not all. We've only found out the Nvidia drivers major version but we'll also need to know the minor version. To get the exact Nvidia driver version, which we'll need for the next step, run this command (should work in any Debian-based Linux distribution, like Ubuntu, Linux Mint and so on):

apt-cache policy NVIDIA-PACKAGE-NAME

Where NVIDIA-PACKAGE-NAME is the Nvidia drivers package name listed in Software & Updates. For example, to see the exact installed version of the nvidia-driver-390 package, run this command:

$ apt-cache policy nvidia-driver-390
nvidia-driver-390:
  Installed: 390.48-0ubuntu3
  Candidate: 390.48-0ubuntu3
  Version table:
 *** 390.48-0ubuntu3 500
        500 http://ro.archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages
        100 /var/lib/dpkg/status

In this command's output, look for the Installed section and note the version numbers (excluding -0ubuntu3 and anything similar). Now we know the exact version of the installed Nvidia drivers (390.48 in my example). Remember this because we'll need it for the next step.

3. And finally, you can install the Nvidia runtime for your installed proprietary Nvidia graphics drivers, from  FlatHub

To list all the available Nvidia runtime packages available on FlatHub, you can use this command:

flatpak remote-ls flathub | grep nvidia

Hopefully the runtime for your installed Nvidia drivers is available on FlatHub. You can now proceed to install the runtime by using this command:

  • For 64bit systems:

flatpak install flathub org.freedesktop.Platform.GL.nvidia-MAJORVERSION-MINORVERSION

Replace MAJORVERSION with the Nvidia driver major version installed on your computer (390 in my example above) and
MINORVERSION with the minor version (48 in my example from step 2).

For example, to install the runtime for Nvidia graphics driver version 390.48, you'd have to use this command:

flatpak install flathub org.freedesktop.Platform.GL.nvidia-390-48

  • For 32bit systems (or to be able to run 32bit applications or games on 64bit), install the 32bit runtime using:

flatpak install flathub org.freedesktop.Platform.GL32.nvidia-MAJORVERSION-MINORVERSION

Once again, replace MAJORVERSION with the Nvidia driver major version installed on your computer (390 in my example above) and MINORVERSION with the minor version (48 in my example from step 2).

For example, to install the 32bit runtime for Nvidia graphics driver version 390.48, you'd have to use this command:

flatpak install flathub org.freedesktop.Platform.GL32.nvidia-390-48

That is all you need to do to get applications or games packaged as Flatpak that are built with OpenGL to run.

2 comments:

  1. it doesn't work.

    flatpak list:
    org.freedesktop.Platform.GL.nvidia-340-106/x86_64/1.4 user,runtime
    org.freedesktop.Platform.GL.nvidia-340-106/x86_64/1.4 system,runtime

    nvidia:
    apt-cache policy nvidia-340
    nvidia-340:
    Установлен: 340.106-0ubuntu3
    Кандидат: 340.106-0ubuntu3
    Таблица версий:
    *** 340.106-0ubuntu3 500


    Still getting error while flatpak run com.moonlight_stream.Moonlight:

    libGL error: No matching fbConfigs or visuals found
    libGL error: failed to load driver: swrast
    00:00:00 - Qt Fatal: Could not initialize GLX

    ReplyDelete
    Replies
    1. Weird, this got Moonlight and other apps to work from Flatpak with Nvidia drivers. I didn't encounter any issues since installing the drivers from FlatHub. I think it's still Nvidia driver related in your case but I'm not sure what's going on.

      Delete

Powered by Blogger.