美文网首页
docker里面进行tensorflow的编译-踩坑记录

docker里面进行tensorflow的编译-踩坑记录

作者: 美环花子若野 | 来源:发表于2019-07-10 10:58 被阅读0次

    先给出最终编译好的文件:链接:https://pan.baidu.com/s/130VQjBT6JXJl0yAOOKJJkw 密码:arf0

    tensorflow-1.12.3-cp36-cp36m-linux_x86_64.whl

    链接:https://pan.baidu.com/s/1V3bNFFClMELeD7ExIvRIsQ 密码:oycm

    tensorflow-1.14.0-cp36-cp36m-linux_x86_64.whl

    ubuntu18.04 86位系统 tensorflow1.12 python 3.6 在docker中编译的结果

    整个编译时间么。。差不多两小时把 = =

    tf1.14配套的版本

    tf 1.14,bazel 0.24.1,gcc,g++ 4.8

    1\apt install git

    2\降低gcc版本,看前面一篇文章 git clone https://github.com/tensorflow/tensorflow.git

    3\然后安装bazel 这里就不装java了  https://docs.bazel.build/versions/master/install-ubuntu.html

    4\https://www.tensorflow.org/install/source?hl=zh-cn 按照这个文档操作,一定注意对应的版本问题

    tf 1.12  gcc 4.8  bazel 0.15这些都是测试通过的,如果自己用高版本很可能碰到意想不到的错误

    5\卸载掉原先掉tensorflow pip uninstall tensorflow

    6\去bazel网站下载0.15的bazel  https://github.com/bazelbuild/bazel/releases?after=0.19.0 

    下载好之后,另外打开一个窗口,通过docker cp的方式  src dst这样 38f30b3590fb这个是打开的容器id

    docker cp /Users/zakj/Downloads/bazel-0.15.0-installer-linux-x86_64.sh 38f30b3590fb:/

    7\然后根据这个文档安装bazel https://docs.bazel.build/versions/master/install-ubuntu.html

    8\这里是很关键的一步骤,git checkout branch_name  # r1.9, r1.10, etc.  一定要ckeckout 到r1.12

    否则会提示bazel需要0.24 这时候gcc版本又不对了,又没人测试过,就完蛋了。这时候还要注意g++的版本

    https://www.tensorflow.org/install/source?hl=zh-cn

    9\接下来的操作很容易了,bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-msse4.1 --copt=-msse4.2  --copt=-mfpmath=both -k //tensorflow/tools/pip_package:build_pip_package

    10\不幸的是,又遇到了错误,错误原因好像是g++版本不对,修改了和gcc对应的4.8的g++版本,又对了

    https://stackoverflow.com/questions/8878676/compile-error-g-error-trying-to-exec-cc1plus-execvp-no-such-file-or-dir/22072238

    https://www.linuxidc.com/Linux/2016-08/134546.htm

    终于大功告成

    docker 使用手册 https://yeasy.gitbooks.io/docker_practice/introduction/what.html

    /root/.cache/bazel/_bazel_root/68a62076e91007a7908bc42a32e4cff9/external/com_google_absl/absl/base/BUILD.bazel:118:1: C++ compilation of rule '@com_google_absl//absl/base:base' failed (Exit 1)

    通过这个指令,下面这张图我也不知道哪里来的

    不知道哪里来的

    删除原来的镜像 我好像只能先停止再删除 

    docker container prune -f    docker image rm imageid 

    https://yeasy.gitbooks.io/docker_practice/image/rm.html

    https://colobu.com/2018/05/15/Stop-and-remove-all-docker-containers-and-images/

    好吧还是报错来

    ERROR: /root/.cache/bazel/_bazel_root/68a62076e91007a7908bc42a32e4cff9/external/com_google_absl/absl/base/BUILD.bazel:118:1: C++ compilation of rule '@com_google_absl//absl/base:base' failed (Exit 1)

    gcc: error trying to exec 'cc1plus': execvp: No such file or directory

    Target //tensorflow/tools/pip_package:build_pip_package failed to build

    Use --verbose_failures to see the command lines of failed build steps.

    INFO: Elapsed time: 344.642s, Critical Path: 0.13s

    INFO: 0 processes.

    ERROR: /root/.cache/bazel/_bazel_root/68a62076e91007a7908bc42a32e4cff9/external/aws/BUILD.bazel:12:1: C++ compilation of rule '@aws//:aws' failed (Exit 4)

    解决参考:

    1、https://github.com/tensorflow/serving/issues/1245

    2、前面几篇文章

    3、https://www.tensorflow.org/install/docker

    https://stackoverflow.com/questions/34183997/why-am-i-getting-docker-error-c-compilation-of-rule-tensorflow-corekernelhttps://github.com/tensorflow/tensorflow/issues/20677https://blog.csdn.net/lanbeiliu/article/details/90293642 内存不足http://m.sohu.com/a/304842717_99979179 从CPU指令集优化

    #Install bazel

    #download tensorflow src

    #Checkout tagged version

    #./configure

    #Compile

    bazel build -c opt --copt=-march=native //tensorflow/tools/pip_package:build_pip_package

    #bazel build -c opt --copt=-mavx --copt=-msse4.1 --copt=-msse4.2 //tensorflow/tools/pip_package:build_pip_package

    #Build the PIP package

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

    #uninstall previous tensorflow version (if applicable)

    #Install PIP package

    pip install /tmp/tensorflow_pkg/tensorflow-1.2.0rc2-cp27-cp27m-macosx_10_12_x86_64.whl

    #References

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

    #https://stackoverflow.com/questions/41293077/how-to-compile-tensorflow-with-sse4-2-and-avx-instructions

    #https://en.wikipedia.org/wiki/Advanced_Vector_Extensions#AVX2

    #https://en.wikipedia.org/wiki/SSE4

    #https://en.wikipedia.org/wiki/FMA_instruction_set

    #https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/x86-Options.html#x86-Options

    #https://gcc.gnu.org/onlinedocs/gcc-4.5.3/gcc/i386-and-x86_002d64-Options.html

    相关文章

      网友评论

          本文标题:docker里面进行tensorflow的编译-踩坑记录

          本文链接:https://www.haomeiwen.com/subject/hbjckctx.html