Unable to run @tensorflow/tfjs-node in Alpine linux
See original GitHub issueTensorFlow.js version
1.0.1
Describe the problem or feature request
Hi I’m trying to run tjfs-node in a Docker node:8-alpine image. I managed to install tfjs and tfjs-node but when I try to run my js code I get the following error:
Registration of backend tensorflow failed
Error: Error relocating /home/app/function/node_modules/@tensorflow/tfjs-node/build/Release/libtensorflow.so: __memcpy_chk: symbol not found
at Object.Module._extensions..node (module.js:682:18)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at bindings (/home/app/function/node_modules/bindings/bindings.js:84:48)
at /home/app/function/node_modules/@tensorflow/tfjs-node/dist/index.js:49:60
at Environment.registerBackend (/home/app/function/node_modules/@tensorflow/tfjs-core/dist/environment.js:439:27)
at Object.<anonymous> (/home/app/function/node_modules/@tensorflow/tfjs-node/dist/index.js:48:8)
Dockerfile
FROM node:8-alpine
RUN addgroup -S app && adduser app -S -G app
RUN apk --no-cache add curl \
&& echo "Pulling watchdog binary from Github." \
&& curl -sSL https://github.com/openfaas/faas/releases/download/0.9.14/fwatchdog > /usr/bin/fwatchdog \
&& chmod +x /usr/bin/fwatchdog \
&& apk del curl --no-cache
RUN apk --no-cache --virtual .build-deps add \
python \
make \
g++ \
&& apk --no-cache --virtual .canvas-build-deps add \
build-base \
cairo-dev \
jpeg-dev \
pango-dev \
giflib-dev \
pixman-dev \
pangomm-dev \
libjpeg-turbo-dev \
freetype-dev \
&& apk --no-cache --virtual .tensorflow-build-deps add \
libc6-compat \
alpine-sdk \
&& apk --no-cache add \
pixman \
cairo \
pango \
giflib \
libjpeg \
libc6-compat
WORKDIR /root/
# Turn down the verbosity to default level.
ENV NPM_CONFIG_LOGLEVEL warn
RUN mkdir -p /home/app
# Wrapper/boot-strapper
WORKDIR /home/app
COPY package.json ./
# This ordering means the npm installation is cached for the outer function handler.
RUN npm i --production
# Copy outer function handler
COPY index.js ./
# COPY function node packages and install, adding this as a separate
# entry allows caching of npm install runtime dependencies
WORKDIR /home/app/function
COPY function/*.json ./
RUN npm i --production || :
RUN apk del .build-deps --no-cache \
&& apk del .canvas-build-deps --no-cache \
&& apk del .tensorflow-build-deps --no-cache
# Copy in additional function files and folders
COPY --chown=app:app function/ .
WORKDIR /home/app/
# chmod for tmp is for a buildkit issue (@alexellis)
RUN chmod +rx -R ./function \
&& chown app:app -R /home/app \
&& chmod 777 /tmp
USER app
ENV cgi_headers="true"
ENV fprocess="node index.js"
EXPOSE 8080
HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1
CMD ["fwatchdog"]
package.json
{
"name": "function",
"version": "1.0.0",
"description": "",
"main": "handler.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@tensorflow/tfjs": "^1.0.1",
"@tensorflow/tfjs-node": "^1.0.1",
"canvas": "^2.4.0",
"perf_hooks": "0.0.1"
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:14
Top Results From Across the Web
Deploying with `tfjs-node` and missing `libtensorflow.so` file
We've successfully run the app on our local machines, but have encountered an issue running tfjs-node through Heroku (Ubuntu 16.04) and Docker (with...
Read more >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.
Read more >Unable to "npm install @tensorflow/tfjs-node" - Stack Overflow
Finally, i can run TensorFlow.js Node sample on Windows. Indeed, it runs on Ubuntu WSL (Windows Subsystem for Linux).
Read more >docker npm err! tracker "idealtree" already exists - You.com
This issue is happening due to changes in NodeJS starting with version 15. When no WORKDIR is specified, npm install is executed in...
Read more >@tensorflow/tfjs-node - npm
Installing · Installing CPU TensorFlow.js for Node: · Installing Linux/Windows GPU TensorFlow.js for Node: · Windows / Mac OS X Requires Python 2.7....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think
tfjs-node
cannot run on Alpine linux. I have to change to Debian so that I can install necessary dependency. So if you use Docker, my suggestion is to use Debian-based image.This works for me:
I can confirm that I also have this issue.