系统相关
首页 > 系统相关> > 在CentOS7.5上编译和安装TensorFlow的步骤

在CentOS7.5上编译和安装TensorFlow的步骤

作者:互联网

一. 安装Python3

1. 从https://www.python.org/downloads/,下载Python3.6.7

2. 编译python3.6.7

$ ./configure --prefix=/usr/local/python3 --enable-optimizations

$ make

3. 安装python3.6.7

# rm /usr/bin/python

# rm /usr/bin/python-config

# make install

# ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3

# ln -s /usr/bin/python3 /usr/bin/python

# ln /usr/local/python3/bin/python3.6m-config /usr/bin/python3-config

# ln -s /usr/bin/python3-config /usr/bin/python-config

# ln -s usr/local/python3/bin/pip3.6 /usr/bin/pip3

# ln -s /usr/bin/pip3 /usr/bin/pip

二. 安装bazel

1. 检查Java版本

$ rpm -qa | grep java

java-1.8.0-openjdk-headless-1.8.0.161-2.b14.el7.x86_64

java-1.8.0-openjdk-devel-1.8.0.161-2.b14.el7.x86_64

java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64

2. 下载Bazel(如果是tensorflow2.0版本,需要下载bazel2.0.0版本)

在https://github.com/bazelbuild/bazel/releases,下载bazel-0.15.0-dist.zip

3. 编译与安装Bazel

1)解压缩bazel-0.15.0-dist.zip

$ unzip bazel-0.15.0-dist.zip

2)编译bazel

$ ./compile.sh

3)复制bazel到系统目录

$ cd output

$ su

# cp bazel /usr/local/bin

三. 安装TensorFlow

1. 从https://github.com/tensorflow/tensorflow/releases下载tensorflow-1.12.0.tar.gz

2. 安装相关依赖软件

$ python3 -m pip install --user numpy scipy keras wheel

$ cd $HOME/.local

$ su

# cp –r * /usr/local/python3

或者:

# python3 –m pip install numpy scipy keras wheel

3. 编译与安装tensorflow-1.12.0.tar.gz

1)解压缩tensorflow-1.12.0.tar.gz

$ tar zxvf tensorflow-1.12.0.tar.gz

2)配置TensorLlow

$ cd tensorflow

$ ./configure

均选择默认选项即可。

3)编译tensorflow

a)编译支持CPU的软件包

$ bazel build --config=opt --copt=-msse4.1 --copt=-msse4.2 --copt=-mavx --copt=-mavx2 --copt=-mfma //tensorflow/tools/pip_package:build_pip_package

b)编译支持GPU的软件包

# bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

4)生成whl软件包

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

5)安装TensorFlow软件包

# python3 -m pip install /tmp/tensorflow_pkg/tensorflow-1.12.0-cp36-cp36m-linux_x86_64.whl
————————————————
版权声明:本文为CSDN博主「weixin_43138209」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_43138209/article/details/88202742

标签:bin,bazel,编译,usr,tensorflow,pip,TensorFlow,CentOS7.5,python3
来源: https://www.cnblogs.com/liuys635/p/12792619.html