[go: nahoru, domu]

Skip to content
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

Windows 10 electron example app onnxruntime_binding.node not found #487

Open
1 of 5 tasks
samlhuillier opened this issue Dec 29, 2023 · 3 comments
Open
1 of 5 tasks
Labels
bug Something isn't working

Comments

@samlhuillier
Copy link
Contributor
samlhuillier commented Dec 29, 2023

System Info

transformers.js: ^2.6.2
Using the example app here https://github.com/xenova/transformers.js/tree/main/examples/electron
Tried both node 18 & 20 on fresh windows 10 home bootcamp install on an intel mac.

Environment/Platform

  • Website/web-app
  • Browser extension
  • Server-side (e.g., Node.js, Deno, Bun)
  • Desktop app (e.g., Electron)
  • Other (e.g., VSCode extension)

Description

\\?\C:\Users\samto\Desktop\transformers.js\examples\electron\node_modules\onnxruntime-node\bin\napi-v3\win32\x64\onnxruntime_binding.node
    at process.func [as dlopen] (node:electron/js2c/asar_bundle:2:1869)
    at Module._extensions..node (node:internal/modules/cjs/loader:1326:18)
    at Object.func [as .node] (node:electron/js2c/asar_bundle:2:1869)
    at Module.load (node:internal/modules/cjs/loader:1096:32)
    at Module._load (node:internal/modules/cjs/loader:937:12)
    at f._load (node:electron/js2c/asar_bundle:2:13377)
    at Module.require (node:internal/modules/cjs/loader:1120:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (C:\Users\samto\Desktop\transformers.js\examples\electron\node_modules\onnxruntime-node\dist\binding.js:9:1)
    at Module._compile (node:internal/modules/cjs/loader:1241:14) {
  code: 'ERR_DLOPEN_FAILED'
}

Reproduction

On Windows 10 Home:

  1. git clone https://github.com/xenova/transformers.js/tree/main/examples/electron
  2. cd transformers.js\examples\electron
  3. npm i
  4. npm run start
  5. enter something in the text box that appears on screen

Just tested this same flow on a mac and it works fine...
Thanks in advance for any help!

@samlhuillier samlhuillier added the bug Something isn't working label Dec 29, 2023
@xenova
Copy link
Owner
xenova commented Dec 29, 2023

fresh windows 10 home bootcamp install on an intel mac

I would assume this is the issue, and might have something to do with how onnxruntime-node selects which .node file to load depending on the underlying hardware.

cc @fs-eire @guschmue, any ideas?

@samlhuillier
Copy link
Contributor Author
samlhuillier commented Jan 1, 2024

Interesting. I did some research and ran some very basic onnxruntime-node code within the same electron app and the same error occurs so I don't think this is related to transformers.js. Will keep the issue open for now in case there are any other ideas.

@FrozenKiwi
Copy link
FrozenKiwi commented Jan 14, 2024

I believe I'm running into the same issue. (edit, might not be the same issue, didn't realize the original was cloning sample directly. Might leave this here anyway as it's been one helluva rabbit hole and hopefully it helps someone regardless)

If you use the electron-forge webpack template, it has troubles loading (some) native node modules, and it's default config seems to break something (?) in transformers.js

I adapted the default electron template here to work with webpack/typescript: https://github.com/FrozenKiwi/transformers-test. The last 2 commits should give a pretty good idea of what you need to do in your own project to enable this very cool package. But in short:

  1. set externals: [ 'onnxruntime-node', 'sharp', ], on your main webpack config
  2. Disable the asar packaging and associated @electron-forge/plugin-auto-unpack-natives plugin
  3. Use @timfish/forge-externals-plugin to ensure that the native modules are included by webpack

After this, when you make/install, you should see in your packages in /local/app.../resources/app/node_module, and running the app works similar to the provided template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants