Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find EGL device in a headless nvidia cudagl container #124

Open
AlbertYang0112 opened this issue Sep 12, 2024 · 0 comments
Open

Cannot find EGL device in a headless nvidia cudagl container #124

AlbertYang0112 opened this issue Sep 12, 2024 · 0 comments

Comments

@AlbertYang0112
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant