I'm trying to deploy a container to Google CloudRun which lets me use WebGL which is GPU hardware-accelerated.
I have the following front-end code (using node) to initialize WebGL and query its vendor and device:
console.log("Checking WEBGL capabilities...")
const canvas = document.createElement("canvas")
const gl = canvas.getContext("webgl")
if (gl) {
const debugInfo = gl.getExtension("WEBGL_debug_renderer_info")
if (debugInfo) {
const vendor = gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL)
const renderer = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL)
console.log("WEBGL Vendor:", vendor)
console.log("WEBGL Renderer:", renderer)
} else {
console.log("WEBGL_debug_renderer_info not available")
}
} else {
console.log("WebGL not available")
}
The node program is executed using Playwright(1.52.0)/Chromium like so:
const browser = await playwright.chromium.launch({
timeout: timeoutInSeconds * 1_000,
logger: {
isEnabled: () => true,
log: (name, _severity, message) => api.logger.debug(`${name} ${message}`),
},
headless: true,
channel: "chromium",
args: [
//"--use-gl=egl",
"--use-gl=angle",
"--use-angle=gl-egl",
//"--use-angle=gl",
"--ignore-gpu-blocklist",
//"--use-gl=angle",
"--no-sandbox",
"--headless=new",
"--enable-gpu",
"--enable-webgl",
// "--use-angle=vulkan",
// "--enable-features=Vulkan",
// "--disable-vulkan-surface",
// "--enable-unsafe-webgpu",
],
})
const page = await browser.newPage({permissions: ["storage-access"], viewport: {width: 40, height: 40}})
await page.goto(url, {timeout: timeoutInSeconds * 1_000})
The docker base image for the container uses mcr.microsoft.com/playwright:v1.52.0-jammy.
As you can see I have tried many different combinations of flags when spawning Chromium (as trying different "solutions" I found on the web) but never did I see NVIDIA to be used, but always
WEBGL Vendor: Google Inc. (Mesa)
WEBGL Renderer: ANGLE (Mesa, llvmpipe (LLVM 15.0.7 256 bits), OpenGL 4.5)
or
WEBGL Vendor: Google Inc. (Google)
WEBGL Renderer: ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)
depending on the flag-combination, suggesting software-rendering only.
I made sure the container sees the NVIDIA GPU and proper drivers are installed by running nvidia-smi inside the container resulting in this:
| NVIDIA-SMI 535.216.03 Driver Version: 535.216.03 CUDA Version: 12.2 |
|-----------------------------------------+----------------------+----------------------+
| 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 L4 Off | 00000000:00:07.0 Off | 0 |
| N/A 75C P0 N/A / 72W | 0MiB / 23034MiB | 0% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
+---------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=======================================================================================|
| No running processes found |
+---------------------------------------------------------------------------------------+
which suggests GPU and driver being available.
I'm really running out of ideas what else I could try. Does anybody have any further ideas what else to test or which combination of flags actually works ?