pyopengl
pyopengl copied to clipboard
Cannot find EGL device in a headless nvidia cudagl container
Hi, thank you for your repo!
I'm trying to run MuJoCo which uses PyOpenGL as graphic backend in a headless docker container nvidia/cudagl:11.4.2-runtime-ubuntu20.04. I find with EGL in PyOpenGL, my GPU cannot be detected, i.e., eglQueryDevicesEXT
returns a empty list.
However, my GPU is detectable with a simple code written with CPP (from here):
#include <EGL/eglext.h>
void assertEGLError(const std::string& msg) {
EGLint error = eglGetError();
if (error != EGL_SUCCESS) {
std::stringstream s;
s << "EGL error 0x" << std::hex << error << " at " << msg;
throw std::runtime_error(s.str());
}
}
int main(int argc, char *argv[])
{
int deviceID = 0; // TODO hardcode
EGLDisplay eglDpy;
EGLConfig config;
EGLContext context;
EGLint num_config;
static const int MAX_DEVICES = 16;
EGLDeviceEXT eglDevs[MAX_DEVICES];
EGLint numDevices;
PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT =
(PFNEGLQUERYDEVICESEXTPROC)eglGetProcAddress("eglQueryDevicesEXT");
eglQueryDevicesEXT(MAX_DEVICES, eglDevs, &numDevices);
printf("Detected %d devices\n", numDevices);
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT =
(PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
// Choose device by deviceID
eglDpy = eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, eglDevs[deviceID], nullptr);
assertEGLError("eglGetDisplay");
return 0;
}
Which prints Detected 3 devices
. I looked into the dynamic library loaded by PyOpenGL but I find nothing unusual:
load <ctypes.LibraryLoader object at 0x7f4fb0a7b8e0> GLX 256
load <ctypes.LibraryLoader object at 0x7f4fb0a7b8e0> GLESv2 256
load <ctypes.LibraryLoader object at 0x7f4fb0a7b8e0> EGL 256
load <ctypes.LibraryLoader object at 0x7f4fb0a7b8e0> OpenGL 256
Could you please help me with that? Thanks.