tfjs: Unable to run @tensorflow/tfjs-node in Alpine linux
TensorFlow.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"
}
}
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 17 (1 by maintainers)
Commits related to this issue
- fix: use node:18-slim https://github.com/tensorflow/tfjs/issues/1425 — committed to julianpoy/ingredient-instruction-classifier by julianpoy a year ago
I think
tfjs-nodecannot 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.
cc @pyu10055 @lina128