From a2c12a26380f5f3556c25eb411db628d3ac3d431 Mon Sep 17 00:00:00 2001 From: 3dtours Date: Wed, 23 Sep 2026 08:36:03 +0700 Subject: [PATCH] web: ask the GPU for the fast one before an export runs onnxruntime hands a webgpu session whatever adapter the browser picks by default, which on a laptop with both is the one built into the processor: the export then waits on the slow half of the machine for no reason. The runtime reads `env.webgpu.powerPreference` when it builds the webgpu session, so set it to high-performance; a browser with nothing to honour the preference with still falls back to the threaded wasm path exactly as before. --- docker/frontend/src/engine/superRes.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker/frontend/src/engine/superRes.ts b/docker/frontend/src/engine/superRes.ts index 4df9e35..2652241 100644 --- a/docker/frontend/src/engine/superRes.ts +++ b/docker/frontend/src/engine/superRes.ts @@ -51,6 +51,9 @@ function load(): Promise { ort.env.wasm.numThreads = self.crossOriginIsolated ? Math.min(8, navigator.hardwareConcurrency || 1) : 1; + // A laptop with two GPUs would otherwise hand this to the one built into + // the processor. The model is the export, so ask for the fast one. + ort.env.webgpu.powerPreference = 'high-performance'; const session = await ort.InferenceSession.create(MODEL_URL, { executionProviders: ['webgpu'] }).catch(() => ort.InferenceSession.create(MODEL_URL, { executionProviders: ['wasm'] }) );