vulkan is not avaible in lxc / lxd container but opengl is

907 Views Asked by At

I am using ubuntu 18:04 with an lxc / lxd steam container. It works great, I followed this tutorial and did some changes to the network stuff.

https://blog.simos.info/running-steam-in-a-lxd-system-container/

Steam works for opengl games but not for vulkan games. Same for lutris.

Host side:

===========
VULKAN INFO
===========

Vulkan Instance Version: 1.1.70


Instance Extensions:
====================
Instance Extensions     count = 16

Container side:

ubuntu@steam:~$ vulkaninfo

===========
VULKAN INFO
===========

Vulkan Instance Version: 1.1.70

ERROR: setupLoaderTermPhysDevs:  Failed to detect any valid GPUs in the current config
ERROR: setupLoaderTrampPhysDevs:  Failed during dispatch call of 'vkEnumeratePhysicalDevices' to lower layers or loader to get count.

/build/vulkan-UL09PJ/vulkan-1.1.70+dfsg1/demos/vulkaninfo.c:2700: failed with VK_ERROR_INITIALIZATION_FAILED

OpenGL works just fine, games run fast, so it must find my only gpu in the system. Do I have to separately enable vulkan for the container?

The host has no problems with the vulkan smoketest either:

user@host:~$ vulkan-smoketest 
7223 presents in 5.00039 seconds (FPS: 1444.49)
2

There are 2 best solutions below

0
On BEST ANSWER

A reddit user named zakk wrote a solution in the comments of https://blog.simos.info/running-steam-in-a-lxd-system-container/.

After doing some traces, I noticed it is failing to open files in /dev/dri The container has the wrong permissions; on the host those files have an ACL set that lets the current user access them, the container does not. So to fix: in the container run

sudo setfacl -m "u:ubuntu:rw-" /dev/dri/*

You have to execute the setfacl command every time you start lxc.

0
On

That guide adds manually the necessary OpenGL shared libraries in the LXD container, and by doing so, does not add the Vulkan shared libraries.

LXD now supports the NVidia container runtime (provided by NVidia), therefore you can use it instead. Follow the more recent guide at https://blog.simos.info/running-x11-software-in-lxd-containers/