Morecoin https grails arduino nuget spark项目 直销系统源码 matlab读取dat文件 mysql默认密码 mysql删除一列 linux获取当前时间 git下载项目 java创建字符串数组 mysql更新 python如何实现多线程 python加入环境变量 java文档 java调用方法 java方法调用 java对象是什么 java获取url参数 按钮制作 右键菜单背景 jb51 python队列 js图片上传 HTML5从入门到精通 朋友圈访客记录教程 陌陌电脑直播设置教程 画图怎么添加文字 maven项目打包 js转数字 网卡驱动安装包 js刷新当前页 python图片处理 r330不能识别墨盒 黑客攻防技术宝典 vbs代码 globalscape 键盘指法练习游戏
当前位置: 首页 > 学习教程  > 编程语言

Centos 编译TensorFlow C/C++库 libtensorflow.so libtensorflow_framework.so

2020/11/4 13:54:40 文章标签:

安装依赖 yum -y install automake libtool libsysfs libxslt-devel libffi libffi-devel python-devel gcc openssl openssl-devel sqlite-devel pip install six numpy wheel coverage mock 安装CMake 从https://cmake.org/download/选择最新的版本 wget https://github.c…

  • 安装依赖

yum -y install automake libtool libsysfs libxslt-devel libffi libffi-devel python-devel gcc openssl openssl-devel sqlite-devel

pip install six numpy wheel coverage mock

  • 安装CMake

从https://cmake.org/download/选择最新的版本

wget https://github.com/Kitware/CMake/releases/download/v3.14.0-rc4/cmake-3.14.0-rc4-Linux-x86_64.tar.gz

tar -xvf cmake-3.14.0-rc4-Linux-x86_64.tar.gz

mv cmake-3.14.0-rc4-Linux-x86_64 /usr/local/share/cmake

ln -s /usr/local/share/cmake/bin/ccmake /usr/bin/ccmake

ln -s /usr/local/share/cmake/bin/cmake /usr/bin/cmake

ln -s /usr/local/share/cmake/bin/ctest /usr/bin/ctest

  • 安装java

yum -y install java-1.8.0-openjdk*

  • 安装Bazel

从https://github.com/bazelbuild/bazel/releases选择合适的版本,具体版本对应关系在https://tensorflow.google.cn/install/source,tensorflow r1.12对应的应是bazel 0.15.0

wget https://github.com/bazelbuild/bazel/releases/download/0.15.0/bazel-0.15.0-installer-linux-x86_64.sh

sh bazel-0.15.0-installer-linux-x86_64.sh --prefix=/usr/local/share/bazel

ln -s /usr/local/share/bazel/bin/bazel /usr/bin/bazel

  • 下载TensorFlow

git clone https://github.com/tensorflow/tensorflow

或者

git clone https://jhc888007%40163.com:[password]@github.com/tensorflow/tensorflow

cd tensorflow

git checkout r1.12

./configure

接下来有一系列设置(这步好像不是必须的?),不懂的可以用默认值

  • 编译C库

cd tensorflow

bazel build :libtensorflow.so

在../bazel-bin/tensorflow/生成libtensorflow.so和libtensorflow_framework.so

# 问题:

 bazel clean --expunge

 

  • 编译C++库

cd tensorflow

bazel build :libtensorflow_cc.so

在../bazel-bin/tensorflow/生成libtensorflow_cc.so和libtensorflow_framework.so

  • 安装依赖

cd contrib/makefile

./build_all_linux.sh

  • 安装Eigen

cd downloads/eigen

mkdir build

cd build

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/share/eigen ..

make install

cd /usr/local/include

ln -s ../share/eigen/include/eigen3/Eigen

ln -s ../share/eigen/include/eigen3/unsupported

  • 安装Protobuf(实践证明对于1.12版本不兼容,行不通)

cd downloads/protobuf

./autogen.sh

./configure --prefix=/usr/local/share/protobuf

make && make install

如果不成功则make clean,再重新make

vim /etc/profile

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/share/protobuf/lib
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/share/protobuf/lib
export PATH=$PATH:/usr/local/share/protobuf/bin
export PKG_CONFIG_PATH=/usr/local/share/protobuf/lib/pkgconfig/
  • 安装Protobuf(手动)

在https://github.com/protocolbuffers/protobuf/releases找到合适版本

wget https://github.com/protocolbuffers/protobuf/releases/download/v3.6.0/protobuf-all-3.6.0.tar.gz

tar -xvf protobuf-all-3.6.0.tar.gz

cd protobuf-3.6.0/ 

./configure --prefix=/usr/local/share/protobuf

make && make check && make install

vim /etc/profile

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/share/protobuf/lib
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/share/protobuf/lib
export PATH=$PATH:/usr/local/share/protobuf/bin
export PKG_CONFIG_PATH=/usr/local/share/protobuf/lib/pkgconfig/
  •  如果已经有相同系统环境编译好的tensorflow包,则只需要安装依赖环境,然后将已安装的Eigen拷贝到新机器对应位置,然后将编译好的tensorflow包拷贝到python安装目录lib目录下

 

 

 

Centos 安装TensorFlow

Centos 编译TensorFlow C/C++库 libtensorflow.so libtensorflow_framework.so

Centos C/C++库 libtensorflow.so libtensorflow_framework.so 测试

 

 

参考文献:

https://www.cnblogs.com/hrlnw/p/7007648.html

https://www.jianshu.com/p/d46596558640

https://blog.csdn.net/qq_37674858/article/details/81095101

http://www.cnblogs.com/zjutzz/p/10182099.html

https://blog.csdn.net/u010700335/article/details/69422282/

https://www.cnblogs.com/hrlnw/p/7383951.html

https://blog.csdn.net/qq_29936933/article/details/82107861

https://blog.csdn.net/laowulong350/article/details/79001511

https://tensorflow.google.cn/install/source_windows

转载于:https://www.cnblogs.com/jhc888007/p/10518425.html


本文链接: http://www.dtmao.cc/news_show_350032.shtml

附件下载

相关教程

    暂无相关的数据...

共有条评论 网友评论

验证码: 看不清楚?