From 5f61b775b5a7b7be8d4305c894dd61e20f38aa47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C5=8Dshin?= Date: Sat, 28 Oct 2023 13:45:39 -0400 Subject: [PATCH] Correct check for WebGPU support Just testing for the presence of navigator.gpu is not sufficient to establish WebGPU support: in particular, at time of writing, Chrome on Android exposes a navigator.gpu but does not return anything from requestAdapter. Context: https://github.com/microsoft/onnxruntime/issues/15796#issuecomment-1783878252 --- js/web/lib/wasm/jsep/init.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/web/lib/wasm/jsep/init.ts b/js/web/lib/wasm/jsep/init.ts index d66357e729d5d..badfea76c6864 100644 --- a/js/web/lib/wasm/jsep/init.ts +++ b/js/web/lib/wasm/jsep/init.ts @@ -132,7 +132,8 @@ class ComputeContextImpl implements ComputeContext { export const init = async(module: OrtWasmModule, env: Env): Promise => { const init = module.jsepInit; - if (init && navigator.gpu) { + const hasGpu = !!(navigator.gpu && await navigator.gpu.requestAdapter()) + if (init && hasGpu) { if (!env.wasm.simd) { throw new Error( 'Not supported for WebGPU=ON and SIMD=OFF. Please set `env.wasm.simd` to true when using WebGPU EP');