<h3>Short version</h3>

<p>How can I get an integrated-graphics-accelerated headless X display running inside a Google Cloud Kubernetes Engine pod?</p>

<h3>Background</h3>

<p>I'm working on a reinforcement learning project that involves running a large number of simulated environments in parallel. I'm doing the simulations using Google Cloud Kubernetes Engine, with <a href="https://github.com/panda3d/panda3d" rel="nofollow noreferrer">panda3d</a> rendering to an <a href="https://www.x.org/releases/X11R7.6/doc/man/man1/Xvfb.1.xhtml" rel="nofollow noreferrer">Xvfb</a> virtual display.</p>

<p>However, I've noticed that the simulation on my Macbook runs 2x faster than the one on Kubernetes, and profiling suggests the difference is entirely from <a href="https://i.stack.imgur.com/FMkFe.jpg" rel="nofollow noreferrer">drawing the frame</a>. Other operations - like linear algebra - are at most 30% slower. My theory is this is because on my Macbook panda3d can take advantage of the integrated graphics, while Xvfb uses software rendering.</p>

<p>My suspicion - gathering together the info in the links below - is the trick is to get a hardware-accelerated headless X server running, then use Virtual GL to fork it across a second Xvfb display. But lord, I am way out of my depth here.</p>

<h3>Uncertainties</h3>

<ul>
<li>Is hardware vs software rendering actually the source of my slowdown?</li>
<li>Do Google Cloud instances have integrated graphics? </li>
<li>Can a Kubernetes pod use integrated graphics without modifications to the host?</li>
</ul>

<h3>Useful sources</h3>

<ul>
<li><a href="https://arrayfire.com/remote-off-screen-rendering-with-opengl/" rel="nofollow noreferrer">Headless rendering on a VM using an NVidia card</a></li>
<li><a href="http://wiki.ros.org/docker/Tutorials/Hardware%20Acceleration" rel="nofollow noreferrer">Setting up Intel hardware-accelerated docker instances</a>, though it requires some host commands</li>
<li><a href="https://medium.com/@pigiuz/hw-accelerated-gui-apps-on-docker-7fd424fe813e" rel="nofollow noreferrer">NVidia-accelerated hardware rendering in Docker</a></li>
<li><a href="https://virtualgl-users.narkive.com/ysqsq4v3/running-virtualgl-with-xvfb-on-ec2-ubuntu-headless-gpu-instance" rel="nofollow noreferrer">Discussion of combining VirtualGL and Xvfb</a></li>
</ul>

Andy Jones
<p>I will answer your questions in order :</p>

<ul>
<li><p>Most likely yes but it is hard to determine for sure with the information you provided. It depends on how your software and the library you are using (panda3d) handle the rendering. </p></li>
<li><p>Google Cloud Compute Engine instances do not have integrated graphics, but you can always use GPUs (supported GPUs and related zones listed <a href="https://cloud.google.com/compute/docs/gpus/#gpus-list" rel="nofollow noreferrer">here</a>). You can enable virtual displays on certain instances as explained in this <a href="https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display" rel="nofollow noreferrer">document</a>.</p></li>
<li><p>You can setup Kubernetes clusters or node pools in Google Cloud where the nodes are equipped with Nvidia GPUs as it is explained <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/gpus" rel="nofollow noreferrer">here</a>.</p></li>
</ul>

<p>You can take a look in <a href="https://github.com/GoogleCloudPlatform/container-engine-accelerators" rel="nofollow noreferrer">here</a> to check some examples on how to use Kubernetes with GPUs on Google Cloud Platform.</p>
