1.0.1
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)
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"]
{
"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"
}
}
Any progress on how to solve this issue?
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:
FROM node:buster-slim
COPY . .
RUN apt-get update && \
apt-get install -y build-essential \
wget \
python3 \
make \
gcc \
libc6-dev
RUN npm install
EXPOSE 3000
CMD [ "node", "index.js" ]
Is this likely to be resolved soon? Any other workarounds?
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:
FROM node:buster-slim COPY . . RUN apt-get update && \ apt-get install -y build-essential \ wget \ python3 \ make \ gcc \ libc6-dev RUN npm install EXPOSE 3000 CMD [ "node", "index.js" ]
Man !!! you are a saviour ✌🏻
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you.
Closing as stale. Please @mention us if this needs more attention.
Still having this errors was this solved?
I can confirm that I also have this issue.
Most helpful comment
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: