Performance Issue When Running Panda3D Headless in Docker Container

I am using Panda3D to render a video on a Linux server with a GCP L4 GPU. However, I observed a significant performance drop when running the same program inside a Docker container compared to running it directly on the host.

Here is my current PRC configuration:

loadPrcFileData("", "egl-device-index 0")
loadPrcFileData("", "load-display p3headlessgl")
loadPrcFileData("", "window-type offscreen")
loadPrcFileData("", f"win-size 1920 1080")
loadPrcFileData("", "audio-library-name null")

When running outside of the container, the profiling results are:

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
   300    0.968    0.003    0.968    0.003 {method 'renderFrame' of 'panda3d.core.GraphicsEngine' objects}

However, when running inside the container, performance drops significantly:

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
   300   25.383    0.085   25.383    0.085 {method 'renderFrame' of 'panda3d.core.GraphicsEngine' objects}

I have tested two Docker images:

•	pytorch/pytorch:2.3.1-cuda12.1-cudnn8-runtime
•	nvidia/opengl:1.2-glvnd-runtime-ubuntu22.04

Both showed similar performance degradation. I have verified that the container has access to the GPU by running the nvidia-smi command. And there is not any error or warning running this code.

Is there any way to resolve this performance issue?

I found a solution! The nvidia/cudagl:11.2.2-devel-ubuntu20.04 Docker image successfully enabled EGL with CUDA acceleration, resolving the performance issue.

1 Like