Describe the issue
I can succesfully use the ONNX runtime on the web from my main web page, using the following CDN URL and an async SCRIPT tag:
https://cdn.jsdelivr.net/npm/onnxruntime-web@1.20.1/dist/ort.all.min.js
Execution providers such as WASM or WebGPU are working fine.
However, when I do exactly the same thing from a web worker, using importScripts, the importScripts statement runs fine, but the promise returned by ort.InferenceSession.create cannot be waited for - instead, an error happens (see below).
I am not sure what to do at this point. Is this a bug or is this limitation a by-design limitation of web workers? Shall I just host all ORT files on my web server?
My setup:
- Windows 11 24H2
- same result with both Chrome 134 or Edge 135.
- nVidia GTX 1060 GPU with latest drivers
To reproduce
From a web worker:
importScripts("https://cdn.jsdelivr.net/npm/onnxruntime-web@1.20.1/dist/ort.all.min.js"); // succeeds
let onnxRT = ort.InferenceSession.create("http://localhost:7500/model.onnx", {'executionProviders': ['webgpu']}); // succeeds
let awaited = await onnxRT ; // does not succeed
The error is:
http://localhost:7500/ort-wasm-simd-threaded.jsep.mjs
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
no available backend found. ERR: [webgpu] TypeError: Failed to fetch dynamically imported module: http://localhost:7500/ort-wasm-simd-threaded.jsep.mjs
(here it basically says it cannot fetch the resource, this is not a MIME type issue).
Urgency
No response
ONNX Runtime Installation
Released Package
ONNX Runtime Version or Commit ID
See above CDN url.
Execution Provider
'webgpu' (WebGPU)
Describe the issue
I can succesfully use the ONNX runtime on the web from my main web page, using the following CDN URL and an async SCRIPT tag:
https://cdn.jsdelivr.net/npm/onnxruntime-web@1.20.1/dist/ort.all.min.jsExecution providers such as WASM or WebGPU are working fine.
However, when I do exactly the same thing from a web worker, using importScripts, the importScripts statement runs fine, but the promise returned by ort.InferenceSession.create cannot be waited for - instead, an error happens (see below).
I am not sure what to do at this point. Is this a bug or is this limitation a by-design limitation of web workers? Shall I just host all ORT files on my web server?
My setup:
To reproduce
From a web worker:
The error is:
(here it basically says it cannot fetch the resource, this is not a MIME type issue).
Urgency
No response
ONNX Runtime Installation
Released Package
ONNX Runtime Version or Commit ID
See above CDN url.
Execution Provider
'webgpu' (WebGPU)