我正在尝试安装tensorflow,目的是在raspberry pi 4上的node red中安装node-red-contrib-tf-model。我在https://flows.nodered.org/node/node-red-contrib-tf-model上遵循了这些说明
但是,当我运行npm install时,我遇到了错误。
pi@raspberrypi:~/.node-red/node_modules/@tensorflow/tfjs-node $ npm install
> @tensorflow/tfjs-node@1.7.4 install
> node scripts/install.js
CPU-linux-1.7.4.tar.gz
* Downloading libtensorflow
[==============================] 63400/bps 100% 0.0s
* Building TensorFlow Node.js bindings
node-pre-gyp install failed with error: Error: Command failed: node-pre-gyp install --build-from-source
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.14.0
node-pre-gyp info using node@16.20.0 | linux | arm64
node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp info build requesting source compile
gyp info it worked if it ends with ok
gyp info using node-gyp@9.3.1
gyp info using node@16.20.0 | linux | arm64
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@9.3.1
gyp info using node@16.20.0 | linux | arm64
gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/home/pi/.node-red/node_modules/@tensorflow/tfjs-node/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/pi/.cache/node-gyp/16.20.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/home/pi/.cache/node-gyp/16.20.0',
gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/home/pi/.cache/node-gyp/16.20.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/home/pi/.node-red/node_modules/@tensorflow/tfjs-node',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@9.3.1
gyp info using node@16.20.0 | linux | arm64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
In file included from ../binding/tfjs_backend.cc:18:
../binding/tfjs_backend.h:25:10: fatal error: tensorflow/c/c_api.h: No such file or directory
25 | #include "tensorflow/c/c_api.h"
| ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [tfjs_binding.target.mk:114: Release/obj.target/tfjs_binding/binding/tfjs_backend.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
gyp ERR! stack at ChildProcess.emit (node:events:513:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
gyp ERR! System Linux 6.1.34-v8+
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--build-from-source" "--module=/home/pi/.node-red/node_modules/@tensorflow/tfjs-node/lib/napi-v5/tfjs_binding.node" "--module_name=tfjs_binding" "--module_path=/home/pi/.node-red/node_modules/@tensorflow/tfjs-node/lib/napi-v5" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=5" "--node_napi_label=napi-v5"
gyp ERR! cwd /home/pi/.node-red/node_modules/@tensorflow/tfjs-node
gyp ERR! node -v v16.20.0
gyp ERR! node-gyp -v v9.3.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --build-from-source --module=/home/pi/.node-red/node_modules/@tensorflow/tfjs-node/lib/napi-v5/tfjs_binding.node --module_name=tfjs_binding --module_path=/home/pi/.node-red/node_modules/@tensorflow/tfjs-node/lib/napi-v5 --napi_version=8 --node_abi_napi=napi --napi_build_version=5 --node_napi_label=napi-v5' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/home/pi/.node-red/node_modules/@tensorflow/tfjs-node/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (node:events:513:28)
node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1100:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
node-pre-gyp ERR! System Linux 6.1.34-v8+
node-pre-gyp ERR! command "/usr/bin/node" "/home/pi/.node-red/node_modules/@tensorflow/tfjs-node/node_modules/.bin/node-pre-gyp" "install" "--build-from-source"
node-pre-gyp ERR! cwd /home/pi/.node-red/node_modules/@tensorflow/tfjs-node
node-pre-gyp ERR! node -v v16.20.0
node-pre-gyp ERR! node-pre-gyp -v v0.14.0
node-pre-gyp ERR! not ok
我已经按照指示在scripts文件夹中实现了custom-binary.json文件。如何解决这个问题,以便在raspberrypi 4上的node-red上使用tensorflow(尝试导入自定义模型)?
所以,在被告知我试图下载错误的版本后。我进入package.json文件,将tensorflow版本更改为1.7.3。然而,同样的问题依然存在。
pi@raspberrypi:~/.node-red/node_modules/@tensorflow/tfjs-node $ npm install
> @tensorflow/tfjs-node@1.7.3 install
> node scripts/install.js
CPU-linux-1.7.3.tar.gz
* Downloading libtensorflow
[==============================] 63400/bps 100% 0.0s
* Building TensorFlow Node.js bindings
node-pre-gyp install failed with error: Error: Command failed: node-pre-gyp install --build-from-source
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.14.0
node-pre-gyp info using node@16.20.0 | linux | arm64
node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp info build requesting source compile
gyp info it worked if it ends with ok
gyp info using node-gyp@9.3.1
gyp info using node@16.20.0 | linux | arm64
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@9.3.1
gyp info using node@16.20.0 | linux | arm64
gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/home/pi/.node-red/node_modules/@tensorflow/tfjs-node/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/pi/.cache/node-gyp/16.20.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/home/pi/.cache/node-gyp/16.20.0',
gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/home/pi/.cache/node-gyp/16.20.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/home/pi/.node-red/node_modules/@tensorflow/tfjs-node',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@9.3.1
gyp info using node@16.20.0 | linux | arm64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
In file included from ../binding/tfjs_backend.cc:18:
../binding/tfjs_backend.h:25:10: fatal error: tensorflow/c/c_api.h: No such file or directory
25 | #include "tensorflow/c/c_api.h"
| ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [tfjs_binding.target.mk:114: Release/obj.target/tfjs_binding/binding/tfjs_backend.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
gyp ERR! stack at ChildProcess.emit (node:events:513:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
gyp ERR! System Linux 6.1.34-v8+
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--build-from-source" "--module=/home/pi/.node-red/node_modules/@tensorflow/tfjs-node/lib/napi-v5/tfjs_binding.node" "--module_name=tfjs_binding" "--module_path=/home/pi/.node-red/node_modules/@tensorflow/tfjs-node/lib/napi-v5" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=5" "--node_napi_label=napi-v5"
gyp ERR! cwd /home/pi/.node-red/node_modules/@tensorflow/tfjs-node
gyp ERR! node -v v16.20.0
gyp ERR! node-gyp -v v9.3.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --build-from-source --module=/home/pi/.node-red/node_modules/@tensorflow/tfjs-node/lib/napi-v5/tfjs_binding.node --module_name=tfjs_binding --module_path=/home/pi/.node-red/node_modules/@tensorflow/tfjs-node/lib/napi-v5 --napi_version=8 --node_abi_napi=napi --napi_build_version=5 --node_napi_label=napi-v5' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/home/pi/.node-red/node_modules/@tensorflow/tfjs-node/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (node:events:513:28)
node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1100:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
node-pre-gyp ERR! System Linux 6.1.34-v8+
node-pre-gyp ERR! command "/usr/bin/node" "/home/pi/.node-red/node_modules/@tensorflow/tfjs-node/node_modules/.bin/node-pre-gyp" "install" "--build-from-source"
node-pre-gyp ERR! cwd /home/pi/.node-red/node_modules/@tensorflow/tfjs-node
node-pre-gyp ERR! node -v v16.20.0
node-pre-gyp ERR! node-pre-gyp -v v0.14.0
node-pre-gyp ERR! not ok
以便尝试从头开始重新安装。我使用以下命令删除node_modules文件。
rm -rf ~/.node-red/node_modules
npm install
但是,此方法导致node_modules目录中缺少@tensorflow文件夹...我怎么才能让它再次出现呢?我试过:
npm install @tensorflow/tfjs-node@1.7.3
但无济于事D;
1条答案
按热度按时间fwzugrvs1#
看来您的系统还没有安装Tensorflow for C。请尝试此link中的解决方案来安装它:
1.检查是否安装了tensorflow本身
1.然后安装绑定:
然后再次尝试安装Tensoflow