From 22a9a1a630c6f171df3e6cba017737cefae13f3f Mon Sep 17 00:00:00 2001 From: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Date: Mon, 15 May 2023 18:09:31 -0700 Subject: [PATCH] [js/webgpu] only register webgpu backend when it's available (#15922) ### Description only register webgpu backend when it's available --- js/web/lib/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/web/lib/index.ts b/js/web/lib/index.ts index 41024de108..e3851755a3 100644 --- a/js/web/lib/index.ts +++ b/js/web/lib/index.ts @@ -16,7 +16,7 @@ if (!BUILD_DEFS.DISABLE_WEBGL) { if (!BUILD_DEFS.DISABLE_WASM) { const wasmBackend = require('./backend-wasm').wasmBackend; - if (!BUILD_DEFS.DISABLE_WEBGPU) { + if (!BUILD_DEFS.DISABLE_WEBGPU && typeof navigator !== 'undefined' && navigator.gpu) { registerBackend('webgpu', wasmBackend, 5); } registerBackend('cpu', wasmBackend, 10);