0

I am working with tensorflowjs in node. when i run the code, "const tf = require('@tensorflow/tfjs-node');" it throw an error "zsh: illegal hardware instruction node app.js".

i am using macbook air M1 chip.

1 Answer 1

1

Official @tensorflow/tfjs-node does not support Apple's M1 CPU just yet

There are unofficial ways to make it work (by using M1 build of tensorflow.so and rebuilding NodeJS bindings), but that is anything but trivial

UPDATE: as requested, a bit more info

there is Apple's port of Tensorflow that works on M1, but Apple stopped developing it and last update is from ~2 years: https://github.com/apple/tensorflow_macos

and there are several 3rd party ports, for example https://towardsdatascience.com/installing-tensorflow-on-the-m1-mac-410bb36b776

also, suggest going through TF's GitHub for M1 issues: https://github.com/tensorflow/tensorflow/issues?q=M1

in either case, once you have tensorflow, you still need to manually rebuild @tensorflow/tfjs-node so it binds to it which is non-trivial.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the response. Can you explain the one you mentioned, or can you share any links.
I find it funny that I get this error trying to run the node.js version of the examples of github.com/justadudewhohacks/face-api.js, but, the browser examples run smoothly and don't have any kind of errors... any hint of why this different behaviour? This makes me think its not a M1 related issue... or is it?
when you're running in browser, you're running JS compiled to pseudo-code interpreted and executed by browser (and in case of WebGL backend, GLSL code compiled to WebGL), never native instructions. so its normal that you see issue with tfjs-node which tries to run native CPU instructions and not in browser.
thanks for clarifying. i've hit a wall, do you recommend any of the ports above to be able to run it server side?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.