gpuvulkanlxclxd

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


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)

Solution

  • 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.