Tensorflow 编译c++调用所需动态库(1)
版本选择
- linux
https://tensorflow.google.cn/install/source
版本 Python 版本 编译器 构建工具 tensorflow-1.12.0 2.7、3.3-3.6 GCC 4.8 Bazel 0.15.0 tensorflow-1.11.0 2.7、3.3-3.6 GCC 4.8 Bazel 0.15.0 tensorflow-1.10.0 2.7、3.3-3.6 GCC 4.8 Bazel 0.15.0 tensorflow-1.9.0 2.7、3.3-3.6 GCC 4.8 Bazel 0.11.0 tensorflow-1.8.0 2.7、3.3-3.6 GCC 4.8 Bazel 0.10.0 tensorflow-1.7.0 2.7、3.3-3.6 GCC 4.8 Bazel 0.10.0 tensorflow-1.6.0 2.7、3.3-3.6 GCC 4.8 Bazel 0.9.0 tensorflow-1.5.0 2.7、3.3-3.6 GCC 4.8 Bazel 0.8.0 tensorflow-1.4.0 2.7、3.3-3.6 GCC 4.8 Bazel 0.5.4 tensorflow-1.3.0 2.7、3.3-3.6 GCC 4.8 Bazel 0.4.5 tensorflow-1.2.0 2.7、3.3-3.6 GCC 4.8 Bazel 0.4.5 tensorflow-1.1.0 2.7、3.3-3.6 GCC 4.8 Bazel 0.4.2 tensorflow-1.0.0 2.7、3.3-3.6 GCC 4.8 Bazel 0.4.2
环境
虚拟机 | 系统 | python | gcc | |
---|---|---|---|---|
vmware | centos7 | python-3.5 | gcc-4.8.5 | 联网 |
编译tensorflow动态库调用
选择tensorflow-1.4.0 python3.5 bazel 0.5.4
-
安装bazel
.\bazel-0.5.4-installer-linux-x86_64.sh
-
增加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空间已经增加成功 -
以下是空间不足引起的错误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