Skip to content

WebGPU backend not found in webworkers #7914

Open
@batman4444

Description

@batman4444

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)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions