You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Subsequently, TensorFlow.js reports that it could not initialize any backends.
From investigating, it appears Deno’s WebGPU implementation disallows reusing the same GPUAdapter object after a device has been created; the adapter becomes “invalidated.” Meanwhile, TensorFlow.js’s WebGPU backend tries to re-query or re-initialize the adapter in a way that triggers this problem.
import * as tf from "@tensorflow/tfjs-core";
import "@tensorflow/tfjs-backend-webgpu";
await tf.ready();
tf.randomGamma([2, 2], 1).print();
Run in Deno with network access:
deno run --allow-net=cdn.jsdelivr.net main.js
Expected Behavior:
TensorFlow.js successfully initializes the WebGPU backend, and a 2x2 tf.randomGamma output is printed to the console.
Actual Behavior:
Initialization of the WebGPU backend fails, and the runtime logs an error about the adapter being invalidated after device creation.
Additional Context / Thoughts:
The Deno team’s WebGPU implementation invalidates an adapter object immediately after a device is created. This is different from how WebGPU typically behaves in Chromium-based browsers, where multiple device creations are not strictly blocked in this manner.
It appears the TF.js WebGPU backend is designed with the browser’s typical behaviour in mind—hence it tries to re-check or re-create the adapter internally, which fails under Deno’s stricter approach.
Potential Approaches:
If TF.js could cache the adapter/device once and avoid re-requesting or re-creating, it might work around Deno’s behaviour.
Alternatively, if Deno changed its adapter handling to match the browser more closely, this issue might also be resolved.
Would it be possible to adjust the WebGPU backend to handle an adapter that cannot be re-used, or to avoid re-initializing the adapter once a device has already been created?
Thank you for reviewing. I’m happy to provide additional logs or testing if needed.
The text was updated successfully, but these errors were encountered:
Environment:
TensorFlow.js version: 4.22.0 (via CDN)
Backend: @tensorflow/tfjs-backend-webgpu
Deno version: 2.1.10
OS/Platform: Windows 11 x64
Issue Description:
I am attempting to use the TensorFlow.js WebGPU backend under Deno, and it fails during initialization with the following error:
Subsequently, TensorFlow.js reports that it could not initialize any backends.
From investigating, it appears Deno’s WebGPU implementation disallows reusing the same GPUAdapter object after a device has been created; the adapter becomes “invalidated.” Meanwhile, TensorFlow.js’s WebGPU backend tries to re-query or re-initialize the adapter in a way that triggers this problem.
Steps to Reproduce:
deno.json
import_map.json
Expected Behavior:
Actual Behavior:
Additional Context / Thoughts:
Potential Approaches:
Would it be possible to adjust the WebGPU backend to handle an adapter that cannot be re-used, or to avoid re-initializing the adapter once a device has already been created?
Thank you for reviewing. I’m happy to provide additional logs or testing if needed.
The text was updated successfully, but these errors were encountered: