<div dir="ltr"><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(17,17,17);font-family:ubuntu,arial,'libra sans',sans-serif;line-height:19.5px">I have created <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">lxc</code> container of our custom toolchain that has many packages. Related to graphics, I have installed <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">nvidia 367.27</code> driver using the nvidia installer inside this container(called <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">mk7icontainer</code>)</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(17,17,17);font-family:ubuntu,arial,'libra sans',sans-serif;line-height:19.5px">The nvidia driver libraries/binaries are installed at path <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">/usr/share/nvidia</code> path inside this container.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(17,17,17);font-family:ubuntu,arial,'libra sans',sans-serif;line-height:19.5px">I have also installed <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">mesa</code> installed in path <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">/usr</code> inside container.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(17,17,17);font-family:ubuntu,arial,'libra sans',sans-serif;line-height:19.5px">I compiled the <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">glxdemo</code> source code using the command as:</p><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;width:auto;max-height:600px;overflow:auto;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;word-wrap:normal;color:rgb(17,17,17);background-color:rgb(239,240,241)"><code style="margin:0px;padding:0px;border:0px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:inherit">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</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(17,17,17);font-family:ubuntu,arial,'libra sans',sans-serif;line-height:19.5px"><br></p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(17,17,17);font-family:ubuntu,arial,'libra sans',sans-serif;line-height:19.5px">Inside the container, I have</p><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;width:auto;max-height:600px;overflow:auto;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;word-wrap:normal;color:rgb(17,17,17);background-color:rgb(239,240,241)"><code style="margin:0px;padding:0px;border:0px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:inherit">DISPLAY=":0"
XAUTHORITY=/root/.Xauthority
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(17,17,17);font-family:ubuntu,arial,'libra sans',sans-serif;line-height:19.5px">I am starting the <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">bash</code> in the container using below command:</p><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;width:auto;max-height:600px;overflow:auto;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;word-wrap:normal;color:rgb(17,17,17);background-color:rgb(239,240,241)"><code style="margin:0px;padding:0px;border:0px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:inherit">sudo lxc-attach -n mk7icontainer --clear-env -- /usr/bin/bash
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(17,17,17);font-family:ubuntu,arial,'libra sans',sans-serif;line-height:19.5px">My host machine is running <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">Ubuntu 16.0.4</code> and I installed the same <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">nvidia 367.27</code> driver using its installer. It is running fine. I can even run <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">glxdemo</code> on host machine without any issues.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(17,17,17);font-family:ubuntu,arial,'libra sans',sans-serif;line-height:19.5px">However, when I try to run <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">glxdemo</code> inside the container ( compiled using above mentioned command), I get the following error:</p><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;width:auto;max-height:600px;overflow:auto;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;word-wrap:normal;color:rgb(17,17,17);background-color:rgb(239,240,241)"><code style="margin:0px;padding:0px;border:0px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:inherit">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
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(17,17,17);font-family:ubuntu,arial,'libra sans',sans-serif;line-height:19.5px">anyone got any idea what is wrong here?</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(17,17,17);font-family:ubuntu,arial,'libra sans',sans-serif;line-height:19.5px"><br></p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(17,17,17);font-family:ubuntu,arial,'libra sans',sans-serif;line-height:19.5px"><br></p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(17,17,17);font-family:ubuntu,arial,'libra sans',sans-serif;line-height:19.5px">Source code for <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(239,240,241)">glxdemo</code> is :<br></p><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;width:auto;max-height:600px;overflow:auto;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;word-wrap:normal;color:rgb(17,17,17);background-color:rgb(239,240,241)"><code style="margin:0px;padding:0px;border:0px;font-family:consolas,menlo,monaco,'lucida console','liberation mono','dejavu sans mono','bitstream vera sans mono','courier new',monospace,sans-serif;white-space:inherit">#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;
}</code></pre></div>