[lxc-users] not able to run glxdemo from inside lxc container

jjs - mainphrame jjs at mainphrame.com
Wed Nov 2 18:05:14 UTC 2016


Thank you for the follow-up - this is a good reference.

Jake

On Wed, Nov 2, 2016 at 10:53 AM, manik sheeri <sheeri185adidam at gmail.com>
wrote:

> I was able to resolve this issue.
>
> I had to add nvidia device nodes in the lxc container config file.
>
> lxc.cgroup.devices.allow = c 195:* rwm
> lxc.mount.entry = /dev/nvidia0 dev/nvidia0 none bind,optional,create=file
> lxc.mount.entry = /dev/nvidiactl dev/nvidiactl none bind,optional,create=file
> lxc.mount.entry = /dev/nvidia-modeset dev/nvidia-modeset none bind,optional,create=file
>
>
> On Wed, Nov 2, 2016 at 5:00 AM, <lxc-users-request at lists.
> linuxcontainers.org> wrote:
>
>> Send lxc-users mailing list submissions to
>>         lxc-users at lists.linuxcontainers.org
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>>         http://lists.linuxcontainers.org/listinfo/lxc-users
>> or, via email, send a message with subject or body 'help' to
>>         lxc-users-request at lists.linuxcontainers.org
>>
>> You can reach the person managing the list at
>>         lxc-users-owner at lists.linuxcontainers.org
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of lxc-users digest..."
>>
>> Today's Topics:
>>
>>    1. not able to run glxdemo from inside lxc container (manik sheeri)
>>    2. Error in playing a sound using ALSA inside LXC container
>>       (manik sheeri)
>>
>>
>>
>> ---------- Forwarded message ----------
>> From: manik sheeri <sheeri185adidam at gmail.com>
>> To: lxc-users at lists.linuxcontainers.org
>> Cc:
>> Date: Tue, 1 Nov 2016 14:09:06 -0700
>> Subject: [lxc-users] not able to run glxdemo from inside lxc container
>>
>> I have created lxc container of our custom toolchain that has many
>> packages. Related to graphics, I have installed nvidia 367.27 driver
>> using the nvidia installer inside this container(called mk7icontainer)
>>
>> The nvidia driver libraries/binaries are installed at path
>> /usr/share/nvidia path inside this container.
>>
>> I have also installed mesa installed in path /usr inside container.
>>
>> I compiled the glxdemo source code using the command as:
>>
>> gcc -g glxdemo.c -Wl,--rpath-link,/usr/share/nvidia/lib -Wl,-rpath,/usr/share/nvidia/lib \
>> -Wl,--rpath-link,/usr/share/nvidia/lib/tls -Wl,-rpath,/usr/share/nvidia/lib/tls \
>> -Wl,--rpath-link,/usr/share/nvidia/lib/vdpau  -Wl,-rpath,/usr/share/nvidia/lib/vdpau \
>> -Wl,--rpath-link,/usr/share/nvidia/lib/xorg/modules -Wl,-rpath,/usr/share/nvidia/lib/xorg/modules \
>> -Wl,--rpath-link,/usr/share/nvidia/lib/xorg/modules/drivers -Wl,-rpath,/usr/share/nvidia/lib/xorg/modules/drivers \
>> -Wl,--rpath-link,/usr/share/nvidia/lib/xorg/modules/extensions -Wl,-rpath,/usr/share/nvidia/lib/xorg/modules/extensions -lX11 -lGL -lGLU -lglut -lm -o glxdemo
>>
>>
>> Inside the container, I have
>>
>> DISPLAY=":0"
>> XAUTHORITY=/root/.Xauthority
>>
>> I am starting the bash in the container using below command:
>>
>> sudo lxc-attach -n mk7icontainer --clear-env  -- /usr/bin/bash
>>
>> My host machine is running Ubuntu 16.0.4 and I installed the same nvidia
>> 367.27 driver using its installer. It is running fine. I can even run
>> glxdemo on host machine without any issues.
>>
>> However, when I try to run glxdemo inside the container ( compiled using
>> above mentioned command), I get the following error:
>>
>> X Error of failed request:  BadValue (integer parameter out of range for operation)
>> Major opcode of failed request:  154 (GLX)
>> Minor opcode of failed request:  3 (X_GLXCreateContext)
>> Value in failed request:  0x0
>> Serial number of failed request:  24
>> Current serial number in output stream:  25
>>
>> anyone got any idea what is wrong here?
>>
>>
>>
>> Source code for glxdemo is :
>>
>> #include <GL/gl.h>
>> #include <GL/glx.h>
>> #include <stdio.h>
>> #include <stdlib.h>
>> static void redraw( Display *dpy, Window w )
>> {
>>    printf("Redraw event\n");
>>    glClear( GL_COLOR_BUFFER_BIT );
>>
>>    glColor3f( 1.0, 1.0, 0.0 );
>>    glRectf( -0.8, -0.8, 0.8, 0.8 );
>>    glXSwapBuffers( dpy, w );
>> }
>>
>> static void resize( unsigned int width, unsigned int height )
>> {
>>    printf("Resize event\n");
>>    glViewport( 0, 0, width, height );
>>    glMatrixMode( GL_PROJECTION );
>>    glLoadIdentity();
>>    glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 );
>> }
>>
>> static Window make_rgb_db_window( Display *dpy,
>>                               unsigned int width, unsigned int height )
>> {
>>    int attrib[] = { GLX_RGBA,
>>                     GLX_RED_SIZE, 1,
>>                     GLX_GREEN_SIZE, 1,
>>                     GLX_BLUE_SIZE, 1,
>>                     GLX_DOUBLEBUFFER,
>>                     None };
>>    int scrnum;
>>    XSetWindowAttributes attr;
>>    unsigned long mask;
>>    Window root;
>>    Window win;
>>    GLXContext ctx;
>>    XVisualInfo *visinfo;
>>
>>    scrnum = DefaultScreen( dpy );
>>    root = RootWindow( dpy, scrnum );
>>
>>    visinfo = glXChooseVisual( dpy, scrnum, attrib );
>>    if (!visinfo) {
>>       printf("Error: couldn't get an RGB, Double-buffered visual\n");
>>       exit(1);
>>    }
>>
>>    /* window attributes */
>>    attr.background_pixel = 0;
>>    attr.border_pixel = 0;
>>    attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
>>    attr.event_mask = StructureNotifyMask | ExposureMask;
>>    mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
>>
>>    win = XCreateWindow( dpy, root, 0, 0, width, height,
>>                     0, visinfo->depth, InputOutput,
>>                     visinfo->visual, mask, &attr );
>>
>>    printf("\n XCreateWindow successfull \n");
>>    ctx = glXCreateContext( dpy, visinfo, NULL, True );
>>    if (!ctx) {
>>       printf("Error: glXCreateContext failed\n");
>>       exit(1);
>>    }
>>
>>         printf("\n glXCreateContext successfull \n");
>>
>>    glXMakeCurrent( dpy, win, ctx );
>>
>>    return win;
>> }
>>
>> static void event_loop( Display *dpy )
>> {
>>    XEvent event;
>>
>>    while (1) {
>>       XNextEvent( dpy, &event );
>>
>>       switch (event.type) {
>>          case Expose:
>>             redraw( dpy, event.xany.window );
>>             break;
>>          case ConfigureNotify:
>>             resize( event.xconfigure.width, event.xconfigure.height );
>>             break;
>>       }
>>    }
>> }
>>
>> int main( int argc, char *argv[] )
>> {
>>    Display *dpy;
>>    Window win;
>>
>>    dpy = XOpenDisplay(NULL);
>>         if(!dpy)
>>         {
>>                 printf("\nError in XOpenDisplay\n");
>>         }
>>         printf("\nXOpenDisplay successfull\n");
>>
>>    win = make_rgb_db_window( dpy, 300, 300 );
>>
>>    printf("\nmake_rgb_db_window successfull \n");
>>    glShadeModel( GL_FLAT );
>>    glClearColor( 0.5, 0.5, 0.5, 1.0 );
>>
>>    XMapWindow( dpy, win );
>>
>>    event_loop( dpy );
>>    return 0;
>> }
>>
>>
>>
>> ---------- Forwarded message ----------
>> From: manik sheeri <sheeri185adidam at gmail.com>
>> To: lxc-users at lists.linuxcontainers.org
>> Cc:
>> Date: Tue, 1 Nov 2016 17:51:26 -0700
>> Subject: [lxc-users] Error in playing a sound using ALSA inside LXC
>> container
>>
>> I am using host Ubuntu 16.0.4 system to run my lxc container. I
>> uninstalled pulseaudio as I wanted to use ALSA directly.
>>
>> After uninstalling pulseaudio from the host machine, I was able to play
>> sounds using the command like one below(on host machine):
>>
>> aplay /usr/share/sounds/alsa/Rear_Right.wav
>>
>> Inside the lxc container, I have installed alsa libs and alsa utils.
>> When I use the same command as above inside the container, I get the
>> following errors:
>>
>> ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
>> ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
>> ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
>> ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
>> ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
>> ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
>> ALSA lib conf.c:4727:(snd_config_expand) Evaluate error: No such file or directory
>> ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM default
>> aplay: main:654: audio open error: No such file or directory
>>
>> The sound devices inside container are:
>>
>> bash-4.2# ls -al /dev/snd/*
>> crw-rw---- 1 root   29 116,  5 Nov  1 17:21 /dev/snd/controlC0
>> crw-rw---- 1 root   29 116,  2 Nov  1 17:21 /dev/snd/controlC1
>> crw-rw---- 1 root   29 116, 10 Nov  1 17:21 /dev/snd/controlC2
>> crw-rw---- 1 root   29 116,  9 Nov  1 17:21 /dev/snd/hwC0D0
>> crw-rw---- 1 root   29 116, 13 Nov  1 17:21 /dev/snd/hwC2D0
>> crw-rw---- 1 root   29 116,  6 Nov  1 17:21 /dev/snd/pcmC0D3p
>> crw-rw---- 1 root   29 116,  7 Nov  1 17:21 /dev/snd/pcmC0D7p
>> crw-rw---- 1 root   29 116,  8 Nov  1 17:21 /dev/snd/pcmC0D8p
>> crw-rw---- 1 root   29 116,  4 Nov  1 17:21 /dev/snd/pcmC1D0c
>> crw-rw---- 1 root   29 116,  3 Nov  1 17:27 /dev/snd/pcmC1D0p
>> crw-rw---- 1 root   29 116, 11 Nov  1 17:21 /dev/snd/pcmC2D3p
>> crw-rw---- 1 root   29 116, 12 Nov  1 17:21 /dev/snd/pcmC2D7p
>> crw-rw---- 1 root   29 116,  1 Nov  1 17:21 /dev/snd/seq
>> crw-rw---- 1 root   29 116, 33 Nov  1 17:21 /dev/snd/timer
>>
>> /dev/snd/by-id:
>> total 0
>> drwxr-xr-x 2 root root  60 Nov  1 17:21 .
>> drwxr-xr-x 4 root root 360 Nov  1 17:21 ..
>> lrwxrwxrwx 1 root root  12 Nov  1 17:21 usb-126c_4.1_amplifier-00 -> ../controlC1
>>
>> /dev/snd/by-path:
>> total 0
>> drwxr-xr-x 2 root root 100 Nov  1 17:21 .
>> drwxr-xr-x 4 root root 360 Nov  1 17:21 ..
>> lrwxrwxrwx 1 root root  12 Nov  1 17:21 pci-0000:00:03.0 -> ../controlC0
>> lrwxrwxrwx 1 root root  12 Nov  1 17:21 pci-0000:00:14.0-usb-0:5:1.0 -> ../controlC1
>> lrwxrwxrwx 1 root root  12 Nov  1 17:21 pci-0000:01:00.1 -> ../controlC2
>>
>>
>> _______________________________________________
>> lxc-users mailing list
>> lxc-users at lists.linuxcontainers.org
>> http://lists.linuxcontainers.org/listinfo/lxc-users
>>
>
>
> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20161102/ee74622e/attachment.html>


More information about the lxc-users mailing list