Can't run TensorFlow JS in a Docker container

Hi
I’m using the JavaScript version of the library. I have struggles to get it running in Docker with the Node Images.

Can somebody help me to get it running? I get errors about missing dependencies.

Dockerfile

FROM node:16-alpine

package.json

"@tensorflow/tfjs-node": "^4.0.0",

Import in a script

import * as tf from "@tensorflow/tfjs-node";

The actual error in the terminal

Error: libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory
findus    |     at Module._extensions..node (node:internal/modules/cjs/loader:1239:18)
findus    |     at Object.nodeDevHook [as .node] (/app/node_modules/ts-node-dev/lib/hook.js:63:13)
findus    |     at Module.load (node:internal/modules/cjs/loader:1033:32)
findus    |     at Function.Module._load (node:internal/modules/cjs/loader:868:12)
findus    |     at Module.require (node:internal/modules/cjs/loader:1057:19)
findus    |     at require (node:internal/modules/cjs/helpers:103:18)
findus    |     at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
findus    |     at Module._compile (node:internal/modules/cjs/loader:1155:14)
findus    |     at Module._compile (/app/node_modules/source-map-support/source-map-support.js:547:25)
findus    |     at Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
findus    | [ERROR] 19:58:30 Error: libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory

maybe @Jason or @ThatJenPerson can help with your question

Looks like you are missing some c lib in your docker image. I am not a expert for Alpine, here are some stackoverflow post that provides a solution.

FYI, you might see other missing libs beyond this one, you might need to follow the same path to fix those.

1 Like

Actually I solved it by using FROM node:16 the base node image, not the alpine or slim one. I also had some problems in the process where docker didn’t update the image properly, which delayed my solution. Thanks for the hints guys!