Tensorflow 编译

Tensorflow 编译c++调用所需动态库(1)

版本选择

  • linux https://tensorflow.google.cn/install/source
    版本Python 版本编译器构建工具
    tensorflow-1.12.02.7、3.3-3.6GCC 4.8Bazel 0.15.0
    tensorflow-1.11.02.7、3.3-3.6GCC 4.8Bazel 0.15.0
    tensorflow-1.10.02.7、3.3-3.6GCC 4.8Bazel 0.15.0
    tensorflow-1.9.02.7、3.3-3.6GCC 4.8Bazel 0.11.0
    tensorflow-1.8.02.7、3.3-3.6GCC 4.8Bazel 0.10.0
    tensorflow-1.7.02.7、3.3-3.6GCC 4.8Bazel 0.10.0
    tensorflow-1.6.02.7、3.3-3.6GCC 4.8Bazel 0.9.0
    tensorflow-1.5.02.7、3.3-3.6GCC 4.8Bazel 0.8.0
    tensorflow-1.4.02.7、3.3-3.6GCC 4.8Bazel 0.5.4
    tensorflow-1.3.02.7、3.3-3.6GCC 4.8Bazel 0.4.5
    tensorflow-1.2.02.7、3.3-3.6GCC 4.8Bazel 0.4.5
    tensorflow-1.1.02.7、3.3-3.6GCC 4.8Bazel 0.4.2
    tensorflow-1.0.02.7、3.3-3.6GCC 4.8Bazel 0.4.2

环境

虚拟机系统pythongcc
vmwarecentos7python-3.5gcc-4.8.5联网

编译tensorflow动态库调用

选择tensorflow-1.4.0 python3.5 bazel 0.5.4

  1. 安装bazel

    .\bazel-0.5.4-installer-linux-x86_64.sh
    
  2. 增加swap空间的命令

    # 生成swap镜像文件
    sudo dd if=/dev/zero of=/mnt/512Mb.swap bs=1M count=512
    # 对该镜像文件格式化
    sudo mkswap /mnt/512Mb.swap
    # 挂载该镜像文件 
    sudo swapon /mnt/4096Mb.swap
    

    使用free -m即可查看到swap空间已经增加成功

  3. 以下是空间不足引起的错误err

    ERROR: /root/.cache/bazel/_bazel_liu/93805c573582deba8265464175fbab9a/external/grpc/BUILD:1332:1: C++ compilation of rule '@grpc//:grpc_resolver_dns_ares' failed (Exit 1) gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -B/usr/bin -B/usr/bin -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF ... (remaining 49 argument(s) skipped)
    
    Use --sandbox_debug to see verbose messages from the sandbox
    external/grpc/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc:23:18: fatal error: ares.h: No such file or directory
    #include <ares.h>
                    ^
    compilation terminated.
    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: 323.591s, Critical Path: 144.99s, Remote (0.00% of the time): [queue: 0.00%, setup: 0.00%, process: 0.00%]
    INFO: 281 processes: 1 local, 280 processwrapper-sandbox.
    FAILED: Build did NOT complete successfully
    
    ERROR: /home/liu/tensorflow-1.12.0/tensorflow/core/kernels/BUILD:903:1: C++ compilation of rule '//tensorflow/core/kernels:tile_ops' failed (Exit 4)
    
    gcc: internal compiler error: Killed (program cc1plus)
    Please submit a full bug report,
    with preprocessed source if appropriate.
    See <http://bugzilla.redhat.com/bugzilla> for instructions.
    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: 7260.987s, Critical Path: 7045.14s
    INFO: 1411 processes: 1411 local.
    FAILED: Build did NOT complete successfully
    
    
    File "/usr/local/python3/lib/python3.5/site-packages/setuptools/package_index.py", line 714, in open_url
    % (url, v.reason))
    distutils.errors.DistutilsError: Download error for https://files.pythonhosted.org/packages/02/24/f73045afb049295b34ac55aaf6ea1592604cda3749632a22e563e66604a3/Cython-0.29.3.tar.gz#sha256=d687fb1cd9df28c1515666174c62e54bd894a6a6d0862f89705063cd47739f83: [Errno 104] Connection reset by peer
    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-g29vic_t/h5py
    
    

参考

yum源更换教程
http://mirrors.163.com/.help/centos.html

https://blog.csdn.net/qq_25109263/article/details/81285952
https://blog.csdn.net/zwx1995zwx/article/details/79064064
https://blog.csdn.net/qq_31261509/article/details/81666763

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值