Search code examples
openglnvidiaheadlessxvfbegl

How to check if OpenGL/EGL detects GPU on a headless server?


I am trying to use NVIDIA's EGL library to render an OpenGL-based simulator in headless mode. However, I find that rendering on the server with EGL is the same speed as rendering on the server with xvfb, which only performs software-based rendering. I'm wondering if my EGL might not be properly detecting my NVIDIA GPU.

What is the best way to check if EGL and OpenGL are properly detecting my GPU?

I tried the following command and find the renderer is set to software-based rather than GPU-based, but I am unsure if this is because I am calling glxinfo with an xvfb:

xvfb-run -a -s "-screen 0 1400x900x24 +extension RANDR -noreset" -- glxinfo | grep "renderer",

which outputs OpenGL renderer string: llvmpipe (LLVM 10.0.0, 256 bits).


Solution

  • However, I find that rendering on the server with EGL is the same speed as rendering on the server with xvfb,

    If your program is using EGL, then it makes zero difference if you run it in a X server or not. The whole purpose of EGL is to completely bypass the neccessity for a X server. And for a offscreen-EGL enabled program it doesn't matter if it's running inside a X environment (be it Xvfb, or Xorg with nvidia driver, proper), because it doesn't care about X.

    I am calling glxinfo with an xvfb:

    glxinfo will never tell you about EGL support.

    In your own program, after establishing the OpenGL context use glGetString to obtain information about the OpenGL implementation you're running on.

    If in your own program, with EGL, glGetString(GL_VENDOR) and glGetString(GL_RENDERER) tell you Nvidia, then you're GPU accelerated.