Electron + Webpack + Transformers.js: Tensor.data must be a typed array for numeric tensor
HelloI’m trying to integrate transformers.js into my Electron Forge app to run the pipeline on the main process (not the renderer).I’ve copy-pasted the example code from theelectron example in the Transformers.js Repo.Here’s a minimalist version of my project that demonstrates the problem. Just runnpm i && npm run startand look at the node output.When running the pipeline I’m getting the following error:removing requested execution provider "wasm" from session options because it is not available: backend not found.
An error occurred during model execution: "TypeError: Tensor.data must be a typed array for numeric tensor.".
Inputs given to model: [Object: null prototype] {
  input_ids: Tensor {
    dims: [ 1, 3 ],
    type: 'int64',
    data: undefined,
    size: 3,
    cpuData: BigInt64Array(3) [ 101n, 7592n, 102n ],
    dataLocation: 'cpu'
  },
  attention_mask: Tensor {
    dims: [ 1, 3 ],
    type: 'int64',
    data: undefined,
    size: 3,
    cpuData: BigInt64Array(3) [ 1n, 1n, 1n ],
    dataLocation: 'cpu'
  }
}
Error occurred in handler for 'run-ai': TypeError: Tensor.data must be a typed array for numeric tensor.
    at Immediate.<anonymous> (C:\path\to\project\transformers-test-project\node_modules\onnxruntime-node\dist\backend.js:45:108)
    at process.processImmediate (node:internal/timers:476:21)The biggest difference between my project and the example project is, that I use webpack to bundle the code - I could imagine it’s a config issue.It looks like it downloads the model fine, it just crashes when running the pipeline.I’m on Windows 11Nodejs v18.19.1I appreciate any help!HF beginner here - please forgive any obvious mistakes.
2024-07-02T22:56:31Z
Hi! Did you end up fixing it? I’m currently stuck with the same problem!
2024-07-03T14:55:51Z
I did, got some help in the HF Discord.For me the problem was that I installed the wrong version of onnxruntime.After installing the same version that’s specified in package-lock.json as a dep of transformers.js, it worked flawlessly.So, to fix it:install transformers.js, but not onnxruntimelook at the onnxruntime version in package-lock.json (ctrl+f onnxruntime)install that version of onnxruntime
2024-07-19T16:18:06Z
It worked like a charm! TYSM!
2024-07-20T04:18:46Z
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.