feat(docker): opt-in GPU acceleration via CLOAKBROWSER_GPU_ACCEL - #476
Open
cjangrist wants to merge 1 commit into
Open
feat(docker): opt-in GPU acceleration via CLOAKBROWSER_GPU_ACCEL#476cjangrist wants to merge 1 commit into
cjangrist wants to merge 1 commit into
Conversation
Adds a gpu_accel flag / CLOAKBROWSER_GPU_ACCEL env var (gpuAccel in JS) that appends GPU-acceleration Chromium flags, with a docker-compose.gpu.yml example and Python/JS parity. gpu_accel is threaded explicitly through launch_context()/launch_context_async() into launch()/launch_async() so it can no longer fall into **kwargs and reach new_context(). Builds on and credits CloakHQ#230 by @mvanhorn, fixing the two defects that stopped it working end-to-end (verified below): - Flag: use --use-gl=angle + --use-angle=gl-egl (ANGLE over native EGL). The original --use-gl=egl is a value removed from modern Chromium (146/150); it silently disables WebGL instead of enabling the GPU. - Image: install the GLVND EGL loader (libglvnd0/libegl1/...) so ANGLE can dlopen native EGL inside the container. Tested on an NVIDIA RTX 3080 Ti, host and inside the built image: SystemInfo / chrome://gpu report hardware WebGL + rasterization on the NVIDIA GL renderer, and a WebGL load drives the GPU to ~90% (nvidia-smi). Unit tests cover flag emission (Python + JS) and gpu_accel forwarding. Closes CloakHQ#189. Co-Authored-By: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #230 by @mvanhorn — keeps that PR's flag/env/JS/test scaffolding and docker-compose example, rebased onto current
main(resolves its conflict). Closes #189.#230 stalled on the one thing it couldn't test: a real GPU. I ran it end-to-end on an NVIDIA RTX 3080 Ti (host + inside the built image); it doesn't work as written, so this fixes two defects:
1 — wrong Chrome flag.
--use-gl=eglwas removed from modern Chromium (the shipped binaries are 146/150); it silently disables WebGL instead of enabling the GPU. Correct:--use-gl=angle --use-angle=gl-egl(ANGLE over native EGL).2 — image missing the GLVND loader. Even with the right flag, ANGLE fails with
Could not dlopen native EGL: libEGL.so.1. The Dockerfile now installslibglvnd0 libegl1 libgles2 libglx0 libopengl0.Testing — NVIDIA RTX 3080 Ti (CDP
SystemInfo.getInfo==chrome://gpu; util fromnvidia-smi)launch(gpu_accel=True, headless=True)/CLOAKBROWSER_GPU_ACCEL=1:--use-gl=egl--use-angle=gl-egl(host)nvidia-smiduring a WebGL load shows the Chrome GPU process at ~90% util (149 W).launch()path (surfaceless EGL). Headed sessions rendered on the container's Xvfb stay on the software driver — Xvfb exposes no GPU display — so this is documented as headless-only rather than over-claimed for the CDP/session path.D3D11string; real backend is LinuxOpenGL ES), so it doesn't leak the real renderer.pytest(build_args flag matrix +gpu_accelforwarding, sync/async),vitestconfig matrix;tscbuild clean.