c++ - 在树莓派上构建 libtensorflow.so 时出错

标签 c++ tensorflow go bazel

问题陈述:我想使用 Golang TensorFlow 在 Raspberry PI 3 中运行我的模型。要使用 TensorFlow,我需要有 libtensorflow.solibtensorflow_framework.so C++ 共享库。

我尝试使用 bazel v0.20.0 从源代码构建,但遇到了问题,最后出错了。

目标: 为 tensorflow r1.11.0 或 r1.12.0 构建 libtensorflow.so

感谢任何帮助。

最佳答案

I found solution:
Couple of things to take care.

***For Tensorflow < v1.5***
Follow instruction here: https://blog.meinside.pe.kr/TensorFlow-and-Go-on-Raspberry-Pi/

***For Tensorflow v1.11.0 - v1.12.0***
Install bazel:
1. Download bazel from link: https://github.com/bazelbuild/bazel/releases
for specific architecture.
2. Install bazel
chmod +x bazel-<version>-installer-linux-<arch>.sh
./bazel-<version>-installer-linux-<arch>.sh --user
Install protobuf:
1. Build/Install protobuf from source.
https://github.com/protocolbuffers/protobuf/blob/master/src/README.md
Build Tensorflow:
1. Git clone
git clone https://github.com/tensorflow/tensorflow.git
2. Check and remove build from specific tensorflow version
go to: tensorflow/tensorflow/tools/ci_build/install/*_toolchain.sh [specific to your linux type and arch]
remove the bazel build and installation like as follows
look for the line: **rm -rf /usr/local/bin/bazel** and remove
and remove **bazel** from line **apt-get install -y ...**

then run 
CI_DOCKER_EXTRA_PARAMS="-e CI_BUILD_PYTHON=python3 -e CROSSTOOL_PYTHON_INCLUDE_PATH=/usr/include/python3.6" tensorflow/tools/ci_build/ci_build.sh PI tensorflow/tools/ci_build/pi/build_raspberry_pi.sh

or 

tensorflow/tools/ci_build/ci_build.sh PI tensorflow/tools/ci_build/pi/build_raspberry_pi.sh 

or 

tensorflow/tools/ci_build/ci_build.sh PI tensorflow/tools/ci_build/pi/build_raspberry_pi.sh PI_ONE

Output:
Output can be found here:
output-artifacts
output-artifacts/tensorflow-1.12.0-cp27-none-linux_armv7l.whl
output-artifacts/libtensorflow_framework.so
output-artifacts/benchmark_model
output-artifacts/libtensorflow.so

Dependency Versions:
Tensorflow       Bazel       protoc
<1.5             0.5.0       3.0 <any>
1.11.0-1.12.0    0.15.2      3.x <any>
>1.12.0          new vers    <any>

关于c++ - 在树莓派上构建 libtensorflow.so 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53874017/

相关文章:

python - 在二维 tf.Variable 中使用 tf.scatter_update

arrays - 在 Go 中,如何将结构转换为字节数组?

go - 如何在本地连接字符串和整数?

docker - 如何让 vim 不要求确认交互?

c++ - 如何在 C++ 中自动打开输入文件?

c++ - 在 OPENFILENAMEW 结构中填充 lpstrFile 时不推荐从字符串常量到 LPWSTR 的转换

c++ - 开发插件: DX or VST?

c++ - 如何使用智能指针跟踪类的对象?

tensorflow - 第一层 MLP 输出在一个 epoch 后为零

python - 教程中发现 TensorFlow 错误