- Node.js v16.17.0
- NPM v8.15.0
- Git LFS
- Python 2.7 or newer
- Clone this repo
- Change to repository directory
- Install all required package
npm i
- node app.js
If app crash and returned "Illegal Insctructions (Core Dumped)", then continue on section D.
Note: If Program running well till showing "Server started on port" then continue to section E
Prebuild tfjs-node shared object comes with optimization for avx2 computation, to check if cpu not supported run this command
grep flags -m1 /proc/cpuinfo | cut -d ":" -f 2 | tr '[:upper:]' '[:lower:]' | { read FLAGS; OPT="-march=native"; for flag in $FLAGS; do case "$flag" in "sse4_1" | "sse4_2" | "ssse3" | "fma" | "cx16" | "popcnt" | "avx" | "avx2") OPT+=" -m$flag";; esac; done; MODOPT=${OPT//_/\.}; echo "$MODOPT"; }
If there is no output like "-mavx2", run this command to used precompiled shared object without avx2 optimization
cp build/prebuild-ubuntu.tar.gz node_modules/@tensorflow/tfjs-node/deps
tar -xf node_modules/@tensorflow/tfjs-node/deps/prebuild-ubuntu.tar.gz
Then try running again
If run app like section C, it will stopped if ssh connection closed or server started, so to handle that using a package named pm2.
- Run
npm i -g pm2
pm2 startup
pm2 startup systems
systemctl status pm2-root.service
cd/<app-directory>
pm2 start app.js -n face-api
pm2 save
- Verify
pm2 status
Reference: https://www.tecmint.com/enable-pm2-to-auto-start-node-js-app/