[Solved] Nvidia Runtime and LXD 3.18 doesnt survive Container Restart

hi fellas
I am trying to isolate gaming from the rest of my Linux Desktop.
So I installed LXD (snap version) on my Manjaro Linux box and granted access to my X (“Xhost +local:”). Inside Container I am running Bionic/18.04 Ubuntu. I have a working config for running nvidia runtime and I am able to fire up (launch) a container with my profile. I can login, and Glxinfo/Glxgears worx fine. Also I can install games and run them smoothly (like 0ad). I have been even able to run (unfortunately without any sound) Steam and CSGO. Pulseaudio is otherwise working inside my container (tried firefox and vlc).

My Issue:
If I restart the container I cant use X Display anymore.

ubuntu@bionic-nvidia3:~$ glxinfo
Error: unable to open display :0

How Do I fix this issue and get NVIDIA Runtime running again without launching a whole new container?

I can reproduce the issue by fireing up a new container. It works at first but after lxc stop/start I am getting said error … I would really appreciate some help… also I would be happy if anybody could give me a hint about the nosound in steam issue… I tried installing all 32bit pulse and alsa related libs in container and hostsystem but couldnt fix it. I am unsure if this could be related to LXD as well…
Thanks and kind regards!

Hi!

Which instructions do you use to get GUI applications to run in a container?

When you restart a container, LXD re-applies the LXD device that shares the host’s X11 socket to the container.

Pulseaudio should work unless Manjaro is doing something a bit differently. In that case, you would need to adapt the instructions.

Thanks for the quick answer! I added some more Details in my original post. My Config/Profile is adapted from one of your posts and looks like that:

[manjaro]$ lxc profile show nvidiagui
config:
  environment.DISPLAY: :0
  nvidia.driver.capabilities: graphics, compute, display, utility, video, compat32
  nvidia.runtime: "true"
  raw.idmap: both 1000 1000
  user.user-data: |
    #cloud-config
    runcmd:
      - 'sed -i "s/; enable-shm = yes/enable-shm = no/g" /etc/pulse/client.conf'
      - 'echo export PULSE_SERVER=unix:/tmp/.pulse-native | tee --append /home/ubuntu/.profile'
    packages:
      - x11-apps
      - x11-utils
      - mesa-utils
      - pulseaudio
description: GUI LXD profile
devices:
  PASocket:
    path: /tmp/.pulse-native
    source: /run/user/1000/pulse/native
    type: disk
  X0:
    bind: container
    connect: unix:/tmp/.X11-unix/X0
    gid: "1000"
    listen: unix:/tmp/.X11-unix/X0
    mode: "0777"
    security.gid: "1000"
    security.uid: "1000"
    type: proxy
    uid: "1000"
  mygpu:
    type: gpu
name: nvidiagui
used_by:
- /1.0/containers/bionic-nvidia
- /1.0/containers/bionic-nvidia2
- /1.0/containers/bionic-nvidia3
- /1.0/containers/bionic-nvidia4

I am sharing my Hosts X Display to container by allowing it via xhost command:

xhost +local:

For audio, check that the Pulseaudio’s socket on the host is indeed /run/user/1000/pulse/native.

For X11 you use a LXD disk device. You can use instead a LXD proxy device (for abstract Unix socket). I have not blogged about this yet but mentioned it on several recent X11 discussions here. I would need to install Manjaro to know what’s wrong but the LXD proxy device is more elegant here.

For audio, check that the Pulseaudio’s socket on the host is indeed /run/user/1000/pulse/native.
The Socket Path its correct. Also Pulseaudio inside the container works with firefox and vlc.

For X11 you use a LXD disk device. You can use instead a LXD proxy device (for abstract Unix socket). I have not blogged about this yet but mentioned it on several recent X11 discussions here. I would need to install Manjaro to know what’s wrong but the LXD proxy device is more elegant here.

I thought I am allready using the Proxy method since I have it in my configs device section:

X0:
bind: container
connect: unix:/tmp/.X11-unix/X0
gid: “1000”
listen: unix:/tmp/.X11-unix/X0
mode: “0777”
security.gid: “1000”
security.uid: “1000”
type: proxy
uid: “1000”

Or am I mistaken and in fact using disk device? Can I find a documentation about that somewhere?

I solved it using abstract unix sockets as adviced and described here in your / simos posts!
I had to change config accordingly and now containers are surviving restarts :slight_smile:

X0:
bind: container
connect: unix:@/tmp/.X11-unix/X0
listen: unix:@/tmp/.X11-unix/X0
security.gid: “1000”
security.uid: “1000”
type: proxy

\ o / Merci Beaucoup!

1 Like

Container restart seems to have fixed the Steam Audio issue as well. Its working now! Yeah!