我在NodeJS中创建了一个Web应用程序,该应用程序使用Tensorflow从经过Python训练的模型中获取预测。我正在尝试通过IBM Cloud的NodeJS Cloud Foundry SDK进行部署。我遇到的问题是当我尝试将项目推送到IBM Cloud时。从控制台中的日志看,似乎TensorflowJS Node在安装并运行时
node-gyp重建
它会引起一些问题。出于某种原因,运行时会遇到错误
/temp/app/node_modules/@tensorflow/tfjs-node/deps/tensorflow/lib/libtensorflow.so:无法识别文件:无法识别文件格式
并从那里引起一连串的错误。有谁知道我该如何解决?
这是命令行日志。
Downloaded build artifacts cache (484.1K)
Staging...
-----> IBM SDK for Node.js Buildpack v3.21-20180628-1258
Based on Cloud Foundry Node.js Buildpack v1.5.24
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NPM_CONFIG_PRODUCTION=true
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version (latest stable) via 'node-version-resolver'
Installing IBM SDK for Node.js (6.14.3) from cache
Using default npm version: 3.10.10
-----> Restoring cache
Loading 2 from cacheDirectories (default):
- node_modules (exists - skipping)
- bower_components (not cached - skipping)
-----> Checking and configuring service extensions before installing
dependencies
-----> Building dependencies
Prebuild detected (node_modules already exists)
Rebuilding any native modules
> protobufjs@6.8.8 postinstall /tmp/app/node_modules/protobufjs
> node scripts/postinstall
> @tensorflow/tfjs-node@0.1.9 install
/tmp/app/node_modules/@tensorflow/tfjs-node
> node-gyp rebuild
make: Entering directory `/tmp/app/node_modules/@tensorflow/tfjs-
node/build'
ACTION binding_gyp_tfjs_binding_target_download_libtensorflow
Release/libtensorflow.so
CXX(target) Release/obj.target/tfjs_binding/binding/tfe_utils.o
CXX(target) Release/obj.target/tfjs_binding/binding/tfjs_backend.o
CXX(target) Release/obj.target/tfjs_binding/binding/tfjs_binding.o
SOLINK_MODULE(target) Release/obj.target/tfjs_binding.node
/tmp/app/node_modules/@tensorflow/tfjs-
node/deps/tensorflow/lib/libtensorflow.so: file not recognized: File
format
not recognized
collect2: error: ld returned 1 exit status
make: *** [Release/obj.target/tfjs_binding.node] Error 1
make: Leaving directory `/tmp/app/node_modules/@tensorflow/tfjs-
node/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit
(/tmp/app/vendor/node/lib/node_modules/npm/node_modules/node-
gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit
(internal/child_process.js:219:12)
gyp ERR! System Linux 4.4.0-109-generic
gyp ERR! command "/tmp/app/vendor/node/bin/node"
"/tmp/app/vendor/node/lib/node_modules/npm/node_modules/node-
gyp/bin/node- gyp.js" "rebuild"
gyp ERR! cwd /tmp/app/node_modules/@tensorflow/tfjs-node
gyp ERR! node -v v6.14.3
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Failed at the @tensorflow/tfjs-node@0.1.9 install script
'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm
installed.
npm ERR! node-gyp rebuild
npm ERR! Linux 4.4.0-109-generic
npm ERR! argv "/tmp/app/vendor/node/bin/node"
"/tmp/app/vendor/node/bin/npm" "rebuild" "--
nodedir=/tmp/app/vendor/node"
npm ERR! node v6.14.3
npm ERR! npm v3.10.10
npm ERR! @tensorflow/tfjs-node@0.1.9 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! If you do, this is most likely a problem with the
@tensorflow/tfjs-node package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! You can get information on how to open an issue for this
project with:
npm ERR! npm bugs @tensorflow/tfjs-node
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls @tensorflow/tfjs-node
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support
request:
npm ERR! /tmp/app/npm-debug.log
-----> Build failed
Some possible problems:
- node_modules checked into source control
http://docs.cloudfoundry.org/buildpacks/node/node-tips.html
- Node version not specified in package.json
http://docs.cloudfoundry.org/buildpacks/node/node-tips.html
Failed to compile droplet: Failed to compile droplet: exit status 1
Exit status 223
Staging failed: STG: Exited with status 223
Stopping instance 4e1dd2ee-71b4-4f84-95e8-c5f6c7bd24e0
Destroying container
Error staging application: App staging failed in the buildpack compile
phase
FAILED
答案 0 :(得分:0)
这是与您的云环境中安装的NodeJ版本有关的问题。错误显示正在使用的NodeJ的版本为Node.js (6.14.3)
,而tensorflowJs需要 Node V8 +
答案 1 :(得分:0)
由于某种原因,如果我从工作目录中删除了node_modules文件夹,然后尝试将其推送到IBM Cloud,那么它将起作用。我的猜测可能是因为Tensorflow安装时会根据您的操作系统以及我的情况
安装某些文件libtensorflow.so
是那些文件之一。