Nvidia-only problem: "libGL error: No matching fbConfigs or visuals found" (solved)

I’m having trouble using opengl in an ubuntu 18.04 or 19.04 container on ubuntu 18.04, and would like to buy a clue :frowning:

To reproduce:

  1. get fresh ubuntu 18.04 system with nvidia card
  2. install proprietary driver with sudo ubuntu-driver autoinstall
  3. verify that glxgears works
  4. verify glxinfo | grep str shows e.g. NVIDIA 390.116
  5. sudo apt install snapd (and log out and back in to get in the group)
  6. sudo snap install lxd (because older lxd is much less happy with nvidia.runtime=true)
  7. spin up an lxc container and verify nvidia-smi works, e.g.
$ cat > mygpu-profile.tmp <<_EOF_
devices:
  gpu:
    type: gpu
  X0:
    path: /tmp/.X11-unix/X0
    source: /tmp/.X11-unix/X0
    type: disk
config:
  environment.DISPLAY: :0
_EOF_
$ lxc profile create mygpu
$ lxc profile edit mygpu < mygpu-profile.tmp
$ lxc launch --profile default --profile mygpu ubuntu:19.04 demo-ubu1904 -c nvidia.runtime=true
$ sleep 10  # (for it to finish starting network?)
$ lxc exec demo-ubu1904 -- sh -c "apt update; apt install -y mesa-utils x11-apps"
$ lxc exec demo-ubu1904 nvidia-smi
Thu May 30 18:16:18 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.116                Driver Version: 390.116                   |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1080    Off  | 00000000:01:00.0  On |                  N/A |
| 27%   34C    P8     7W / 180W |     18MiB /  8117MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
...
  1. Try an X program. Works.
$ xhost +
$ lxc exec demo-ubu1904 xeyes
  1. Now try an opengl program. Boom!
$ lxc exec demo-ubu1904 glxinfo | grep str
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  155 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)

I thought once nvidia-smi worked, I’d be home free, but alas no.

This works with Intel and AMD graphics, fwiw (minus the -c nvidia.runtime=true and nvidia-smi, of course)… so it seems to be nvidia-specific. Does nvidia-container-runtime not support, um, graphics?

Aha, LXD 3.6 has been released mentions another config flag: nvidia.driver.capabilities. Setting that to “graphics” does the trick. Whew!

So either use -c twice when launching on nvidia:

$ lxc launch --profile default --profile mygpu ubuntu:19.04 demo-ubu1904 -c nvidia.runtime=true -c nvidia.driver.capabilities=graphics

or add those two settings to the profile, e.g.

config:
  nvidia.runtime: false
  nvidia.driver.capabilities: "graphics"

for non-nvidia systems, and just flip the false to true for nvidia systems.

1 Like