Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGPU backend not found in webworkers #7914

Open
batman4444 opened this issue Aug 16, 2023 · 7 comments
Open

WebGPU backend not found in webworkers #7914

batman4444 opened this issue Aug 16, 2023 · 7 comments
Assignees

Comments

@batman4444
Copy link

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): Yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 11
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/A
  • TensorFlow.js installed from (npm or script link): Script Links
  • TensorFlow.js version (use command below): 4.10.0
  • Browser version: Chrome 116.0.5845.97
  • Tensorflow.js Converter Version: N/A

Describe the current behavior
Using the following script links, when attempting to load the webGPU backend on a web worker (SharedWorker) I get a "Error: Backend name 'webgpu' not found in registry" error.

If I try loading the same script tags on main thread (not a webworker) it works as expected. Also, the "wasm" and "webgl" backends seems to work as expected.

Describe the expected behavior

SharedWorker should load 'webgpu' backend just like main thread

Standalone code to reproduce the issue

await import("https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@4.10.0/dist/tf.min.js")
await import("https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-webgpu/dist/tf-backend-webgpu.js");
await tf.setBackend("webgpu");

Other info / logs
Uncaught (in promise) Error: Backend name 'webgpu' not found in registry
at e. (engine.js:276:13)
at h (tf.min.js:17:2100)
at Generator. (tf.min.js:17:3441)
at Generator.next (tf.min.js:17:2463)
at u (tf.min.js:17:8324)
at o (tf.min.js:17:8527)
at tf.min.js:17:8586
at new Promise ()
at e. (tf.min.js:17:8467)
at e. (engine.js:293:4)

@batman4444 batman4444 added the type:bug Something isn't working label Aug 16, 2023
@qjia7
Copy link
Collaborator

qjia7 commented Aug 16, 2023

@hujiajie Please help to look at this issue. Thanks.

@hujiajie
Copy link
Contributor

The WebGPU spec says "a GPU object is available in the Window and DedicatedWorkerGlobalScope contexts ...", but not in the SharedWorkerGlobalScope, so I don't think the WebGPU backend could work in shared workers at the moment.

https://gpuweb.github.io/gpuweb/#navigator-gpu

@gyagp
Copy link
Collaborator

gyagp commented Aug 16, 2023

WebGPU Working Group has an issue (gpuweb/gpuweb#4197) to track this.

@batman4444
Copy link
Author

Thanks for the responses. As gyagp pointed out, it looks like there is already an open feature request to address this.

@libofei2004
Copy link

libofei2004 commented Aug 19, 2023

@gyagp @hujiajie Is there no way to use webgpu backend in webworker in webview in android?

@gyagp
Copy link
Collaborator

gyagp commented Aug 20, 2023

WebGPU Android hasn't been released. I didn't follow up the status closely, but you may take a look at this issue: https://bugs.chromium.org/p/dawn/issues/detail?id=286

@libofei2004
Copy link

@gyagp Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants