Running headless


I’m fairly new to panda 3D and am currently doing research on deep q-learning (dql). For my research I wrote a simulation, to train in, in panda3d. But now I know my simulation performs correctly, I want to turn off visualisation. Seeing as turning off visualisations would help speed up the training of the dql algorithm.

I was wondering if it was possible to run panda3D headless. I’ve tried setting the window-type to none, but this gives me error the following error:

File "...", line 209, in __init__
  File "...", line 160, in loadObject
TypeError: NodePath.reparent_to() argument 1 must be panda3d.core.NodePath, not NoneType

I need to be able to get an rgb image of the simulation to use it as a state in the dql algorithm.

Thus, is there a way to not render the window but still to be able to run the simulation in panda3D and having acces to an rgb image of what the window would render if it were visible?

I was also wondering if it was possible to run everything on gpu, as it would also speed up the simulation?

Thanks in advance,

Yes, it is possible to run Panda3D in headless mode. However, in the “none” mode, you don’t get any visual output of any kind, so Panda doesn’t create a camera for you either, hence the error message when you try to parent something to a camera that does not exist.

If you want to render to an image, you probably want to use the “offscreen” mode instead, which creates an offscreen buffer and you still end up with a Camera for rendering to that buffer. You can attach a texture to it in RTMCopyRam mode if you want to get the result back to RAM.

Alternatively, you can continue to use the “none” mode, but you would need to set up your own graphics buffer and camera to render to it.

By default, Panda3D will render your scene on the GPU, although if you want to process the result on the CPU, then that necessitates copying it to RAM (which is slow).

Since GPUs are very different from CPUs, you cannot simply run Python code on the CPU. You could however choose to implement the code that processes the results in a compute shader, which is a generic type of shader program that is executed on the GPU, which can access the results of the simulation render without having to go through system RAM.