Skip to content

WebGPU<-->BigInt: Tensorflow.js - Initialization of backend webgpu failed TypeError: Cannot convert a BigInt value to a number #22029

@josephrocca

Description

@josephrocca

Version: Deno 1.39.4

The code below works in Deno with an earlier tfjs-webgpu-backend version (see import_map.json here), but I raised the tfjs version numbers to 4.16.0 as shown below, and that produces the error logs below. I'm guessing that this is because newer versions of tf.js have started using BigInts, and Deno hasn't implemented some WebGPU<-->BigInt stuff.

I've confirmed that the code below works fine on Chrome (Windows).


deno.json

{
  "importMap": "import_map.json"
}

import_map.json

{
  "imports": {
    "@tensorflow/tfjs-core": "https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-core@4.16.0/dist/tf-core.fesm.js",
    "@tensorflow/tfjs-backend-webgpu": "https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-webgpu@4.16.0/dist/tf-backend-webgpu.fesm.js"
  }
}

main.js

import * as tf from "@tensorflow/tfjs-core";
import "@tensorflow/tfjs-backend-webgpu";

await tf.ready();
tf.randomGamma([2, 2], 1).print();

Error Logs

deno run --unstable --allow-net=cdn.jsdelivr.net main.js
Initialization of backend webgpu failed
TypeError: Cannot convert a BigInt value to a number
    at toNumber (ext:deno_webidl/00_webidl.js:98:11)
    at Array.<anonymous> (ext:deno_webidl/00_webidl.js:255:13)
    at webidl.converters.GPUSize64 (ext:deno_webgpu/01_webgpu.js:5173:42)
    at ext:deno_webidl/00_webidl.js:904:28
    at Array.GPUDeviceDescriptor (ext:deno_webidl/00_webidl.js:788:32)
    at GPUAdapter.requestDevice (ext:deno_webgpu/01_webgpu.js:407:36)
    at Object.factory (https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-webgpu@4.16.0/dist/tf-backend-webgpu.fesm.js:2138:38)
    at async Engine.ready (https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-core@4.16.0/dist/tf-core.fesm.js:4248:29)
    at async file:///home/joe/Downloads/denotfjs/main.js:4:1
error: Uncaught (in promise) Error: Could not initialize any backends, all backend initializations failed.
        throw new Error(`Could not initialize any backends, all backend initializations ` +
              ^
    at Engine.ready (https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-core@4.16.0/dist/tf-core.fesm.js:4254:15)
    at async file:///home/joe/Downloads/denotfjs/main.js:4:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working correctlywebgpuWebGPU API

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions