tfjs: tfjs-node "Illegal instruction: 4" error on macOS Monterey (M1)
System information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS 12.1 (Monterey), 2020 MacBook Air M1
- TensorFlow.js installed from (npm or script link): npm
- TensorFlow.js version: “@tensorflow/tfjs”: “^3.16.0”, “@tensorflow/tfjs-node”: “^3.16.0”
Describe the problem In an empty project, installing and requiring @tensorflow/tfjs-node results in an “Illegal instruction: 4” error thrown.
Provide the exact sequence of commands / steps that you executed before running into the problem
- Create an empty project (
npm init) yarn add @tensorflow/tfjs-nodein project root- create an
index.jsfile and addconst tf = require('@tensorflow/tfjs-node')at the top of the file node index.jsin project root- observe error “Illegal instruction: 4” thrown
As reported in the closed https://github.com/tensorflow/tfjs/issues/4514 ticket, tfjs-node doesn’t appear to work with macOS Monterey. Is there any way to make it work?
Would appreciate any tips, cheers!
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 16
Hi @MikeOBarometer @Caundy I have tried the setup Mike mentioned, it is also working for me. There are couple caveats you need to pay attention to:
This way, your node environment arch matches with tfjs-node binding and TF download. And x86-64 arch that enabled by rosetta would not work with tensorflow (the illegal instruction 4 error), even though all archs match. Please let me know if this would work for you.
Strange! Let me know if I can provide any other system info if it helps. Here’s my versions + arch