xorg - not able to run glxdemo from inside lxc container using nvidia - Ask Ubuntu
i have created lxc
container of our custom toolchain has many packages. related graphics, have installed nvidia 367.27
driver using nvidia installer inside container(called mk7icontainer
)
the nvidia driver libraries/binaries installed @ path /usr/share/nvidia
path inside container.
i have installed mesa
installed in path /usr
inside container.
i compiled glxdemo
source code using 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 container, have
display=":0" xauthority=/root/.xauthority
i starting bash
in container using below command:
sudo lxc-attach -n mk7icontainer --clear-env -- /usr/bin/bash
my host machine running ubuntu 16.0.4
, installed same nvidia 367.27
driver using installer. running fine. can run glxdemo
on host machine without issues.
however, when try run glxdemo
inside container ( compiled using above mentioned command), following error:
x error of failed request: badvalue (integer parameter out of range 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 idea wrong here?
i want know how read these errors narrow down problem.
source code glxdemo
:
#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 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; }
i able resolve issue.
i had add nvidia
device nodes in 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
Comments
Post a Comment