Skip to content

Commit

Permalink
Correct check for WebGPU support
Browse files Browse the repository at this point in the history
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: microsoft#15796 (comment)
  • Loading branch information
mrdomino committed Oct 28, 2023
1 parent 24f9c1a commit 5f61b77
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion js/web/lib/wasm/jsep/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ class ComputeContextImpl implements ComputeContext {

export const init = async(module: OrtWasmModule, env: Env): Promise<void> => {
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');
Expand Down

0 comments on commit 5f61b77

Please sign in to comment.