1.前言
因为在Ubuntu16.04跑segmap需要从源码编译tensorflow
2.安装bazel
我的bazel版本是0.16.1
sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python
chmod +x bazel-0.16.1-installer-linux-x86_64.sh
./bazel-0.16.1-installer-linux-x86_64.sh --user
gedit ~/.bashrc
export PATH="$PATH:$HOME/bin"
3.编译tensorflow
我下载的tensorflow版本是1.8
创建python虚拟环境
$ sudo apt-get install python-numpy python-dev python-pip python-wheel python-virtualenv
$ virtualenv ~/segmappyenv
$ source ~/segmappyenv/bin/activate
(segmappyenv)$ pip install --upgrade pip
(segmappyenv)$ pip install catkin_pkg empy pyyaml
之后在虚拟环境segmappyenv中操作
./configure (除了cuda支持,其余全部默认即可)
bazel build --config=opt --config=cuda framework_shared_object=true tensorflow:libtensorflow_cc.so
官方的推荐是
bazel build --config=opt --define framework_shared_object=true tensorflow:libtensorflow_cc.so
生成Python软件包,在tensorflow-r1.8文件夹下执行
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
4.eigen问题
...
java.io.IOException: Error downloading [https://mirror.bazel.build/bitbucket.org/eigen/eigen/get/6913f0cf7d06.tar.gz
...
在tensorflow路径下找到workspace.bzl
找到关键字eigen_archive,修改内容为
tf_http_archive(
name = "eigen_archive",
urls = [
"https://mirror.bazel.build/bitbucket.org/eigen/eigen/get/6913f0cf7d06.tar.gz",
"https://bitbucket.org/eigen/eigen/get/6913f0cf7d06.tar.gz",
],
sha256 = "791b836cacd03e20bae5bdd25f1c4a5505a0a9975ba94a61eb4e2631fbd1d53a",
strip_prefix = "eigen-eigen-6913f0cf7d06",
build_file = clean_dep("//third_party:eigen.BUILD"),
patch_file = clean_dep("//third_party:eigen_fix_cuda_compilation.patch")
)
这一点对我是适用的,不知道对其他版本的tensorflow怎么样.
参考
https://www.cnblogs.com/chenlinchong/p/12576699.html
https://blog.csdn.net/ziliwangmoe/article/details/84373222
https://github.com/ethz-asl/segmap/issues/108
https://www.jianshu.com/p/5d31cf657841