Got nothing returned when calling renderSceneInto() in headless mode

Hi, Community

When running in headless mode, my program encounters some problems. I use simple-pbr in my program and it works fine with NVIDIA-A6000/A5000/1080ti/A100 in headless mode, while fails to run on Nvidia-V100 GPU. According to the error message, we can conclude that when initialization simple-pbr, renderSceneInto() fails to return a texture for rendering.

I have no idea why this happened. Is it caused by requesting wrong framebuffer properties or failing to initialize EGL?

Panda3D is installed via pip and prc config is:

loadPrcFileData("", "window-title {}".format(EDITION))
loadPrcFileData("", "framebuffer-multisample 1")
loadPrcFileData("", "multisamples 8")
loadPrcFileData("", 'bullet-filter-algorithm groups-mask')
loadPrcFileData("", "audio-library-name null")
loadPrcFileData("", "model-cache-compressed-textures 1")
loadPrcFileData("", "textures-power-2 none")
loadPrcFileData("", "garbage-collect-states 0")
loadPrcFileData("", "compressed-textures 1")

The error message is as follows.

Known pipe types:
glxGraphicsPipe
(1 aux display modules not yet loaded.)
:display:x11display(error): Could not open display ":0.0".
:display:egldisplay(warning): Couldn't initialize the default EGL display: EGL_NOT_INITIALIZED
:display(warning): FrameBufferProperties available less than requested.
requested: depth_bits=1 color_bits=3 red_bits=1 green_bits=1 blue_bits=1 alpha_bits=1 multisamples=8 back_buffers=1 force_hardware
got: depth_bits=32 color_bits=24 red_bits=8 green_bits=8 blue_bits=8 alpha_bits=8 back_buffers=1 force_hardware
:display(error): Could not get requested FrameBufferProperties; abandoning window.
requested: depth_bits=24 float_color color_bits=48 red_bits=16 green_bits=16 blue_bits=16 alpha_bits=16 multisamples=16 force_hardware
got: depth_bits=24 float_color color_bits=48 red_bits=16 green_bits=16 blue_bits=16 alpha_bits=16 stencil_bits=8 multisamples=1 force_hardware

File "/home/stevenlee/miniconda3/envs/driving/lib/python3.7/site-packages/simplepbr/init.py", line 136, in init
self._setup_tonemapping()
File "/home/stevenlee/metadriving/metadrive/metadrive/engine/core/our_pbr.py", line 87, in _setup_tonemapping
self.tonemap_quad.set_shader(tonemap_shader)
AttributeError: 'NoneType' object has no attribute 'set_shader'

I think I’ve ran into this issue before on a personal project where I wanted to render images with a headless client.

It’s likely caused by the fact that the display window can’t be discovered;
tonemap_quad is generated from a FilterManager method render_scene_into. This method returns a NodePath that can be empty.
I believe I boiled it down to an issue related to some default nodes (camera, for instance) failing to initialize correctly due to the lack of a display window, and it just dominoed effect from there.

I’d look into packages you can install that allows you to have a virtual framebuffer. I personally used sudo apt-get install xvfb xserver-xephyr -y but I’d recommend you do some quick research to make sure it’s the right tool to use wrt your GPU.

1 Like

The problem has nothing to do with FilterManager, or with default nodes not being initialized. Panda doesn’t need a display window if you set window-type offscreen.

So, Panda asked EGL to initialize the display, but EGL returned a failure. That means you don’t have a functional OpenGL driver capable of headless rendering. You should update your drivers. Or it’s a problem with your system setup.

Note that you probably want to set load-display p3headlessgl to skip Panda loading the X11-based display module, if you know you don’t have an X11 server.

1 Like

@loonaticx @rdb Thank you so much!