Closed nkreeger closed 5 years ago
After some investigation, the problem is that @tensorflow/tfjs-node is not installed in the base Heroku system. With some hint from this post, I did the following and have a tfjs-node example up and running:
1) run heroku run /bin/bash
to enter a one-off dyno bash prompt
2) run npm install @tensorflow/tfjs-node
3) start the process (I tried with this example and ran node index.js
)
But it does not work after quit the bash prompt and start the process again without install tfjs-node later. More investigation required to make @tensorflow/tfjs-node stay in heroku forever.
Quick updates:
the job works fine on Google Cloud Platform.
for heroku:
(1) run heroku stack:set cedar-14 -a APPNAME
,
(2) open heroku bash prompt, run yarn
or npm install
, or only install tfjs-node with yarn add @tensorflow/tfjs-node
or npm install @tensorflow/tfjs-node
(3) start the job, it works fine. But next time when starting the job, it has the same error.
Tried with clean node_modules cache and run yarn update --pattern @tensorflow/tfjs-node
post install, still doesn't work. Working with heroku support to locate root cause (heroku ticket: https://help.heroku.com/tickets/609604).
Hi @kangyizhang, In your comment (https://github.com/tensorflow/tfjs/issues/517#issuecomment-407232197) you mention that you were able to deploy tfjs-node app to GCP, was there anything specific you had to do in order to deploy?
I get the same error while deploying to GCP. Error: libtensorflow.so: cannot open shared object file: No such file or directory.
Did you have to bundle the node_modules/@tensorflow from your local while deploying?
I'm having the same issue on GCP using Cloud Functions: Error: libtensorflow.so: cannot open shared object file
.
Looking through the documentation, i found that Cloud Functions have a read-only file-system. Is it possible that this blocks the install process from downloading or installing what needs to make this work?
Is it possible to specify the download/install directory of libtensorflow.so? or download the correct version for the platform manually and somehow link it to tfjs-node?
thanks!
Hello, everyone! Solved this issue by using docker container Steps to reach the solution:
Add heroku.yml
build:
docker:
web: Dockerfile
run:
web: node app.js
Add DockerFile
FROM node:10
WORKDIR /
COPY package.json /
RUN npm install
COPY . /
CMD node app.js
Set heroku stack:set container
in CLI to use DockerFile instead of ProcFile
Commit changes and push with git push heroku master
After that, Docker image will be created on Heroku-side and you application will launch.
P.S. Some useful links: https://buddy.works/guides/how-dockerize-node-application https://devcenter.heroku.com/articles/build-docker-images-heroku-yml https://devcenter.heroku.com/articles/container-registry-and-runtime#unsupported-dockerfile-commands Keep in mind, that you do not need EXPOSE command to open PORT as Heroku will give a port dynamically, just use process.env.PORT in your node application. Heroku will do everything on its own!
Thanks for the research everyone! @kangyizhang if you can add instructions in the README of our repo with the steps required to run tfjs-node on GCP and Heroku, that would be fantastic. Thanks!
@dsmilkov that makes sense. I'll add GUIDE about how to deploy tfjs-node job on GCP and Heroku.
The GUIDE has been added: https://github.com/tensorflow/tfjs-website/blob/master/docs/guide/node_in_cloud.md
From the mailing list:
"My team and I are working on deploying a web app that uses a TFJS model powered by Node, rather than WebGL. 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 an Alpine image). The same error shows up in both setups.
When requiring tfjs-node, the backend registration fails looking for libtensorflow.so. I've double-checked that the file libtensorflow.so is present in the directory that tfjs-node/scripts/download-libtensorflow.sh is looking for it in. This is the setup that we've been running on our local machines without a problem.
Here's the error from Heroku bash:
~ $ node
Even with the fix shipped in 0.1.9 this is still happening. Some investigation is needed to figure out why the Node process can't find the library on Heroku.