参考文档

  1. http://www.cnblogs.com/jojodru/p/7744630.html 在Ubuntu 16.04上使用bazel交叉编译tensorflow
  2. https://docs.bazel.build/versions/master/install-ubuntu.html Ubuntu安装Bazel文档
  3. https://github.com/samjabrahams/tensorflow-on-raspberry-pi/blob/master/GUIDE.md 在树莓派上本地编译tensorflow
  4. https://github.com/bazelbuild/bazel/wiki/Building-with-a-custom-toolchain Building with a custom toolchain
  5. https://tensorflow.google.cn/install/install_sources Installing TensorFlow from Sources

ARM-Linux交叉编译

本部分详细介绍了Tensorflow针对Arm-Linux操作系统的源码编译,主要内容是参考《在Ubuntu 16.04上使用bazel交叉编译tensorflow》而来。本文档中介绍的编译方法是使用X86_64机器的Ubuntu环境下进行Tensorflow ARM版本的交叉编译,和网上能查到的大部分(例如参考文档3)直接在树莓派3上编译Tensorflow的方式不同。直接在树莓派3(或其他ARM开发板)上编译会避免很多编译错误,但是编译时间非常长(长达数天),并且由于编译过程中需要消耗大量内存所以还需要额外用TF卡映射交换空间才能保证编译过程不会因为缺少内存而崩溃。另外直接在树莓派3(或其他ARM开发板)上编译Tensorflow会导致编译出来的文件的适用范围比较小,如果你需要评估多款不同ARM开发板,那么你将花费多余的时间针对每块开发板都做一次编译。所以更好的解决方式是通过bazel进行交叉编译。

安装Bazel

准备交叉编译链

新建Bazel交叉编译脚本

添加nsync的交叉编译支持

编译tensorflow主体部分

bazel build --copt="-fPIC" --copt="-march=armv8-a" --cxxopt="-fPIC" --cxxopt="-march=armv8-a"  \
    --verbose_failures --crosstool_top=//arm_compiler:toolchain --cpu=armv8 --config=opt \
    tensorflow/examples/label_image/...

Tensorflow训练环境安装

训练环境概述:

  • CPU:Intel i7-4790K
  • GPU:1 x Nvidia GTX1060
  • 操作系统:Ubuntu 16.04.3 64位
  • GPU驱动版本:384.98
  • CUDA版本:9.0.176
  • cuDNN版本:7.0.4.31
  • 环境搭建时间:2017-12-26

本文档先介绍最简单的Python Pip安装方式

results matching ""

    No results matching ""