Hello we are developing opengl applications inside docker on Pegasus machine using offscreen rendering. However so far we can only access the mesa opengl software device, the two GPUs are not accessible. I tried a small test program which works fine on the host but not in the docker.
Here is the output from the host:
Detected 4 devices
Device 0 description: EGL_NV_device_cuda EGL_EXT_device_drm
Device 1 description: EGL_NV_device_cuda EGL_EXT_device_drm
Device 2 description: EGL_EXT_device_drm
Device 3 description: EGL_MESA_device_software
Here is the output inside the docker
Detected 2 devices
Device 0 description: EGL_EXT_device_drm
Device 1 description: EGL_MESA_device_software
The simple test program:
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <iostream>
static const EGLint configAttribs[] = {
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
EGL_BLUE_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_RED_SIZE, 8,
EGL_DEPTH_SIZE, 8,
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
EGL_NONE
};
static const int pbufferWidth = 9;
static const int pbufferHeight = 9;
static const EGLint pbufferAttribs[] = {
EGL_WIDTH, pbufferWidth,
EGL_HEIGHT, pbufferHeight,
EGL_NONE,
};
int main(int argc, char *argv[])
{
// 1. Initialize EGL
static const int MAX_DEVICES = 20;
EGLDeviceEXT eglDevs[MAX_DEVICES];
EGLint numDevices;
PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT =
(PFNEGLQUERYDEVICESEXTPROC)eglGetProcAddress("eglQueryDevicesEXT");
eglQueryDevicesEXT(MAX_DEVICES, eglDevs, &numDevices);
//MW_INFO("Detected {} devices\n", numDevices);
std::cout<<"Detected "<<numDevices<<" devices"<<std::endl;
PFNEGLQUERYDEVICESTRINGEXTPROC eglQueryDeviceStringEXT =
(PFNEGLQUERYDEVICESTRINGEXTPROC)eglGetProcAddress("eglQueryDeviceStringEXT");
for(int i=0;i<numDevices;i++){
const char *attr = eglQueryDeviceStringEXT(eglDevs[i], EGL_EXTENSIONS);
//MW_INFO("Device {} description: {}",i, attr);
std::cout<<"Device "<<i<<" description: "<<attr<<std::endl;
}
EGLDisplay eglDpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
EGLint major=0, minor=0;
eglInitialize(eglDpy, &major, &minor);
std::cout<<"version="<<major<<"."<<minor<<std::endl;
// 2. Select an appropriate configuration
EGLint numConfigs;
EGLConfig eglCfg;
eglChooseConfig(eglDpy, configAttribs, &eglCfg, 1, &numConfigs);
// 3. Create a surface
EGLSurface eglSurf = eglCreatePbufferSurface(eglDpy, eglCfg,
pbufferAttribs);
// 4. Bind the API
eglBindAPI(EGL_OPENGL_API);
// 5. Create a context and make it current
EGLContext eglCtx = eglCreateContext(eglDpy, eglCfg, EGL_NO_CONTEXT,
NULL);
std::cout<<"eglCtx="<<eglCtx<<std::endl;
eglMakeCurrent(eglDpy, eglSurf, eglSurf, eglCtx);
// from now on use your OpenGL context
// 6. Terminate EGL when finished
eglTerminate(eglDpy);
return 0;
}
I did a lot of research trying to import all the GPU devices into the docker while start the container, tried to use nvidia/cudagl et al, but I have no success. Please kindly give me some idea on this. Thanks
