Hardware Acceleration for Headless Chrome with Nvidia GPU

Hello everyone,

I’m trying to server-side-render a frame of a WebGL2 application in a performant way. To do so, I’m using Puppeteer with headless Chrome inside a Docker container running Ubuntu 20.04.4 on WSL2 on Windows 10 22H2. However, I can’t get any hardware acceleration to become active. It seems that Chrome doesn’t detect my Nvidia GTX1080 card, while on the host system with headless: false it’s being used and increases render performance drastically.

I have followed the tutorial here to install the CUDA toolkit on WSL2.

A container spun up using sudo docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark uses the GTX1080.

Running nvidia-smi inside the container shows the following:

`
±----------------------------------------------------------------------------+
| NVIDIA-SMI 525.65 Driver Version: 527.37 CUDA Version: 12.0 |

|-------------------------------±---------------------±---------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce … On | 00000000:01:00.0 On | N/A |
| N/A 49C P8 10W / N/A | 871MiB / 8192MiB | 0% Default |
| | | N/A |
±------------------------------±---------------------±---------------------+
±----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
`

Using flags like

--ignore-gpu-blocklist --enable-gpu-rasterization --enable-zero-copy --use-gl=desktop / --use-gl=egl

did not solve the problem.

I also tried libosmesa6 with --use-gl=osmesa which had no effect.

I’m starting my container with docker-compose including the following section into the service’s block:

deploy: resources: reservations: devices: - driver: nvidia count: 1 capabilities: [gpu]

Chrome version is HeadlessChrome/108.0.5351.0. The Chrome WebGL context’s WEBGL_debug_renderer_info tells me vendor: Google Inc. (Google) renderer: ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)

Visiting chrome://gpu with Puppeteer shows me this.

Any ideas what might still be missing to have Chrome use the GPU for hardware acceleration?

Best regards
Tobias