-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
GPUAdapter invalidation causes TensorFlow.js WebGPU backend to fail — Follow-up to #22029 #28135
Comments
Fixed in #27665 |
Can you please provide a link or any guide on how to implement it? |
@desaisoftwaree not sure I understand what you are asking for |
I am not able to understand why is this issue closed immediately. It would be great if you can provide any hints. |
I believe this issue has been already resolved and is not yet released so you can try |
I upgraded to canary but the same error persists. |
My understanding is that there is a divergence between Chrome's implementation and wgpu (used by Firefox and Deno) due to changes in the WebGPU spec. Perhaps a fix on the TensorFlow.js side might be appropriate. @crowlKats What do you think? |
You are correct
|
Version: Deno 2.1.10
(stable, release, x86_64-pc-windows-msvc)
v8 13.0.245.12-rusty
typescript 5.6.2
Library:
TensorFlow.js 4.22.0 (WebGPU backend)
Description: This is a follow-up to the now-closed issue #22029. The core problem persists: using the TensorFlow.js WebGPU backend under Deno leads to adapter invalidation errors.
When TensorFlow.js attempts to initialize the WebGPU backend, it eventually tries to re-check the same GPUAdapter (after a device is created). Deno immediately invalidates a GPUAdapter after the first device creation, causing:
deno run --allow-net=cdn.jsdelivr.net main.js
Initialization of backend webgpu failed
TypeError: The adapter cannot be reused, as a device creation has invalidated it
at GPUAdapter.get info (ext:deno_webgpu/01_webgpu.js:525:13)
at Object.factory (https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-webgpu@4.22.0/+esm:170:749)
at async Vs.ready (https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-core@4.22.0/+esm:186:1575)
at async file:///D:/Dev/deno-web-gpu/main.js:4:1
error: Uncaught (in promise) Error: Could not initialize any backends, all backend initializations failed.
at Vs.ready (https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-core@4.22.0/+esm:186:1658)
at async file:///D:/Dev/deno-web-gpu/main.js:4:1
Steps to Reproduce:
deno.json
import_map.json
Expected Behavior: In browsers (e.g., Chrome, Edge), the WebGPU adapter is not invalidated right after device creation. TensorFlow.js’s WebGPU backend can repeatedly query or reuse the adapter without failing. Ideally, Deno would match the browser’s behaviour closely enough that TF.js does not crash on startup.
Actual Behavior: Deno invalidates the GPUAdapter as soon as a device is created. TensorFlow.js tries to re-check or reuse the adapter, triggering a TypeError: The adapter cannot be reused, as a device creation has invalidated it.
Why This Matters:
Additional Context:
Possible Approaches:
Align Deno’s WebGPU adapter lifecycle closer to the browser behaviour so that libraries like TensorFlow.js can function without changes.
Provide a configuration or override that allows multiple device creations or repeated adapter queries.
Thank you for revisiting this. Looking forward to any updates or clarifications on whether Deno can (or will) change its WebGPU behaviour, or if library developers need to implement a workaround to accommodate Deno’s stricter handling.
The text was updated successfully, but these errors were encountered: