Closed reillyeon closed 1 year ago
Running tfjs webgpu on node requires webgpu on node, however there isn't any official webgpu on node support, as described here: https://bugs.chromium.org/p/dawn/issues/detail?id=1762.
A local workaround is here: https://github.com/axinging/webgpu-node-demo/blob/main/tfjs-on-external-node/README.md
Please check that whether !!globalThis.navigator?.gpu
instead of !!globalThis.navigator.gpu
in isWebGPUSupported()
can fix your issue. And feel free to submit a PR for it. Thanks.
Hi, @reillyeon
Apologize for the delayed response and I was trying to replicate the same issue from my end and I'm also getting the same error which you mentioned above in your issue template, please refer above comments from @axinging and @qjia7 and see is it resolving your issue or not ? Thank you
For reference I have added error log below:
(base) gaikwadrahul-macbookpro:test-8066 gaikwadrahul$ node
Welcome to Node.js v18.17.0.
Type ".help" for more information.
> await import('@tensorflow/tfjs-backend-webgpu')
Uncaught TypeError: Cannot read properties of undefined (reading 'gpu')
at isWebGPUSupported (/Users/gaikwadrahul/Desktop/TFJS/test-8066/node_modules/@tensorflow/tfjs-backend-webgpu/dist/tf-backend-webgpu.node.js:1208:35)
at Object.<anonymous> (/Users/gaikwadrahul/Desktop/TFJS/test-8066/node_modules/@tensorflow/tfjs-backend-webgpu/dist/tf-backend-webgpu.node.js:2117:5)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
>
@reillyeon It seems that @mattsoulanille just fixed this issue 2 hours ago by #8070. Thanks for your contribution.
System information
Describe the current behavior Under Node.js the
globalThis
object does not have anavigator
property, sinceisWebGPUSupported()
tries to access a property onglobalThis.navigator
an exception is thrown. I believe that this regressed in #8001.Describe the expected behavior
isWebGPUSupported()
should returnfalse
in non-browser contexts like Node (unless a Node WebGPU is available as suggested in #7595).Standalone code to reproduce the issue
Create an empty npm project, install
@tensorflow/tjfs-backend-webgpu
and then try to invokeimport('@tensorflow/tjfs-backend-webgpu')
on the Node REPL.Other info / logs