I have tested Webots headless mode in docker as described here in Ubuntu 20.04.
In the headless mode, if we make gpus available to the docker container as follows
docker run --gpus=all -it cyberbotics/webots:latest
xvfb-run webots --stdout --stderr --batch --mode=realtime /path/to/your/world/file
This seems to launch Webots without GPUs (hardware acceleration). This is, to my knowledge, because xvfb will use software acceleration.
I believe that GPUs will speed up the simulations for cameras and video recordings, so in that case, I'd like to use GPUs in the headless.
This is the output with xvfb-run webots.... You can see that Webots warns that the system is below minimum. With GUI + GPU in docker, I don't get warnings or it runs nearly as fast as a native installation.
xvfb-run webots --stdout --stderr --batch --mode=fast /usr/local/webots/projects/robots/clearpath/moose/worlds/moose_demo.wbt
WARNING: It is not recommended to run Webots as root.
WARNING: System below the minimal requirements.
Webots has detected that your GPU vendor is 'Mesa/X.org'. A recent NVIDIA or AMD graphics adapter is highly recommended to run Webots smoothly. Webots has detected that your computer uses a slow 3D software rendering system. It is strongly recommended to install the latest graphics drivers provided by your GPU manufacturer. Webots will run much faster after the installation of the correct driver.
- Shadows have been deactivated.
- Anti-aliasing has been deactivated.
- Main 3D view global ambient occlusion has been de-activated.
- Texture quality has been reduced.
- Texture maximum filtering has been reduced due to GPU limitations.
- Anisotropic texture filtering is not supported by the GPU.
You can try to re-activate some OpenGL features from the Webots preferences.
WARNING: Cannot initialize the sound engine: Cannot initialize OpenAL default device 'OpenAL Soft'
Are there any ways of using hardware acceleration in the headless mode? Some use cases are running Webots containers through CI/CD on headless servers.