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

cannot load tfjs-backend-wasm on jsdelivr properly via importScripts. #3908

Closed
y-ich opened this issue Sep 11, 2020 · 3 comments
Closed

cannot load tfjs-backend-wasm on jsdelivr properly via importScripts. #3908

y-ich opened this issue Sep 11, 2020 · 3 comments

Comments

@y-ich
Copy link

y-ich commented Sep 11, 2020

This template is for miscellaneous issues not covered by the other issue categories.

For questions on how to work with TensorFlow.js, or support for problems that are not verified bugs in TensorFlow.js, please go to StackOverflow.

Hi.
I tried loading tfjs-backend-wasm on jsdelivr via importScripts but failed.
tfjs-backend-wasm seems to load tfjs-backend-wasm-threaded-simd.wasm/tfjs-backend-wasm.wasm from a site's base address, not from jsdelivr.

I think that the below is a related issue.
emscripten-core/emscripten#5104

Copying wasm files as the site resources solves this issue, but apparently it is not a good solution.
Are there any workarounds?

Thanks.

@rthadur rthadur self-assigned this Sep 11, 2020
@rthadur
Copy link
Contributor

rthadur commented Sep 11, 2020

@y-ich you need to specify the version from NPM.
please check README

@annxingyuan
Copy link
Contributor

Hi @y-ich - thanks for trying out the WASM backend. The tf-backend-wasm.js file will by default assume that the WASM binaries are located in the same directory. To override this behavior (e.g. if you're using the WASM backend with a bundler), please see this section of the README: https://github.com/tensorflow/tfjs/tree/master/tfjs-backend-wasm#using-bundlers

I think you should be able to resolve your issue by using tf.wasm.setWasmPaths.

@y-ich
Copy link
Author

y-ich commented Sep 12, 2020

@rthadur san, @annxingyuan san, thank you for your advices!

importScripts(
    "//cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js",
    "//cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf-backend-wasm.min.js"
);
tf.wasm.setWasmPaths("//cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/");

solved my issue.
(The last "/" of the path was very important^^)

@y-ich y-ich closed this as completed Sep 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants