gpt4 book ai didi

python-3.x - Raspberry Pi3 上的 Tensorflow 1.5

转载 作者:行者123 更新时间:2023-12-04 01:42:58 30 4
gpt4 key购买 nike

我按照以下说明编译了 tensorflow: https://github.com/samjabrahams/tensorflow-on-raspberry-pi/blob/master/GUIDE.md

我从 github 上拉了最新的 bazel (0.9.0) 并编译成功。之后我从 github 上拉了最新的 tensorflow (1.5.0) 然后应用了这个命令

grep -Rl 'lib64' | xargs sed -i 's/lib64/lib/g'

我跳过了 tensorflow/workspace.bzl 的编辑。然后我运行了配置脚本并提供了 python 3.5 的路径。使用教程中的以下命令,一晚后编译成功:

bazel build -c opt --copt="-mfpu=neon-vfpv4" --copt="-funsafe-math-optimizations" --copt="-ftree-vectorize" --copt="-fomit-frame-pointer" --local_resources 1024,1.0,1.0 --verbose_failures tensorflow/tools/pip_package:build_pip_package

然后我构建了包:

bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

然后用python安装也没有报错:

sudo pip3 install /tmp/tensorflow_pkg/tensorflow-1.5.0rc1-cp35-cp35m-linux_armv7l.whl --upgrade --force-reinstall

但是当我从我的主目录启动 python3 并尝试导入 tensorflow 时:import tensorflow as tf 出现以下错误:

Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170124] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /usr/local/lib/python3.5/dist-packages/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: _ZN10tensorflow9ConcatCPUINS_8bfloat16EEEvPNS_10DeviceBaseERKSt6vectorISt10unique_ptrINS_6TTypesIT_Li2EiE11ConstMatrixESt14default_deleteIS9_EESaISC_EEPNS8_6MatrixE

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /usr/local/lib/python3.5/dist-packages/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: _ZN10tensorflow9ConcatCPUINS_8bfloat16EEEvPNS_10DeviceBaseERKSt6vectorISt10unique_ptrINS_6TTypesIT_Li2EiE11ConstMatrixESt14default_deleteIS9_EESaISC_EEPNS8_6MatrixE


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.

我该如何解决这个问题?提前致谢!

最佳答案

它正在寻找这里定义的 ConcatCPU: https://github.com/tensorflow/tensorflow/blob/r1.5/tensorflow/core/kernels/concat_lib_cpu.cc#L51

undefined symbol: _ZN10tensorflow9ConcatCPUINS_8bfloat16EEEvPNS_10DeviceBaseERKSt6vectorISt10unique_ptrINS_6TTypesIT_Li2EiE11ConstMatrixESt14default_deleteIS9_EESaISC_EEPNS8_6MatrixE

所以你的 bazelrc 可能有问题。

您有多种选择:

1) 挖掘你的 bazelrc 并检查 concat_lib_cpu.cc 是否正在编译,检查链接器是否看到它,等等。

2) 推荐 - 只需从 ci.tensorflow.org 下载软件包并安装:

python 3:http://ci.tensorflow.org/view/Nightly/job/nightly-pi-python3/lastSuccessfulBuild/

python 2:http://ci.tensorflow.org/view/Nightly/job/nightly-pi/lastSuccessfulBuild/

3) 如果可以,请使用 Tensorflow Lite,记住 RPI 是有限的。

祝你好运。

关于python-3.x - Raspberry Pi3 上的 Tensorflow 1.5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48553812/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com