[lxc-users] Recipe for running opengl apps inside LXC with proprietary nvidia driver?

Dan Kegel dank at kegel.com
Wed Apr 23 00:36:25 UTC 2014


So here's what I've tried so far:

On Ubuntu 12.04, I created an Ubuntu 12.04 container.
Per http://unix.stackexchange.com/questions/18003/linux-lxc-deploying-images-with-tiniest-possible-x11
I added

 lxc.cgroup.devices.allow = c 4:10 rwm    # /dev/tty10 X Desktop
 lxc.cgroup.devices.allow = c 195:* rwm  # /dev/nvidia Graphics card
 lxc.cgroup.devices.allow = c 13:* rwm   # /dev/input/* input devices

to the container's config file, then started it.

Inside it, I did
  apt-get install nvidia-current xinit
and then (per the web page above)

  # display vt device
  mknod -m 666 /dev/tty10 c 4 10
  # NVIDIA graphics card devices
  mknod -m 666 /dev/nvidia0 c 195 0
  mknod -m 666 /dev/nvidiactl c 195 255
  # input devices
  mkdir  /dev/input
  chmod 755 /dev/input
  mknod -m 666 /dev/input/mice c 13 63

and then finally
  sudo xinit -- /usr/bin/X vt10 -novtswitch
(note the VT number has to match the one created above).

That seemed to work to the extent that I could put things in
~/.xinitrc, e.g.
 xterm -e "sh -c 'glxinfo | grep string; sleep 10'"
or
 glxgears
and have them work.  I haven't gotten input working yet.



On Tue, Apr 22, 2014 at 4:27 PM, Dan Kegel <dank at kegel.com> wrote:
> Or does one normally run a separate X in a separate virtual terminal
> for LXC, just as one does for multiple users?  So ctl-alt-F7 is
> for the normal desktop, and ctl-alt-F8 could be for the X inside LXC.
>
> cf.
> http://www.cyberciti.biz/faq/running-multiple-x-sessions/
>
> On Tue, Apr 22, 2014 at 4:20 PM, Dan Kegel <dank at kegel.com> wrote:
>> Does anyone have a recipe for running opengl apps in a container
>> on a host with an nvidia graphics card yet?
>>
>> I know the nvidia driver has to be installed and loaded in the host's kernel
>> (of course).  Where does X have to run -- can it be on the host,
>> the container, or either?
>>
>> I can start fooling around given past posts, just wondering if anyone
>> has summed up the current state of things in an easy to use form.
>>
>> https://lists.linuxcontainers.org/pipermail/lxc-users/2013-February/004696.html
>> says it just works (assuming you do a few things)
>>
>> https://lists.linuxcontainers.org/pipermail/lxc-users/2011-April/001817.html
>> says it works (assuming you follow a long list of steps)
>>
>> https://www.redhat.com/archives/libvir-list/2013-May/msg01653.html
>> hints that it works with just a few tweaks
>>
>> https://www.redhat.com/archives/libvir-list/2013-June/msg00013.html
>> says libvirt does it better
>>
>> http://unix.stackexchange.com/questions/18003/linux-lxc-deploying-images-with-tiniest-possible-x11
>> talks about it a bit, and has similar long list of steps
>>
>> (https://www.stgraber.org/2012/11/16/running-steam-in-a-lxc-container/
>> hints at one,
>> http://www.vislab.uq.edu.au/howto/lxc/nvidia.html shows how to at
>> least build such apps in the container,
>> http://www.jonnor.com/2010/03/hardware-passthrough-in-lxc-or-running-a-desktop-in-a-cgroup/
>> talks about it for vesa,
>> http://blog.mraw.org/2011/04/05/Running_X_from_LXC/ talks about it for
>> open source driver
>> https://wiki.openstack.org/wiki/HeterogeneousGpuAcceleratorSupport
>> talks about doing it for CUDA
>> )


More information about the lxc-users mailing list