我的CPU是i7 9700K。由于官方安装包没用AVX AVX2编译,所以需要自己源码编译构建。
下载
- tensorflow2.1.0-RC1:下载地址:https://github.com/tensorflow/tensorflow/archive/v2.1.0-rc1.tar.gz
- bazel-0.29.1: 需要使用bazel对tensorflow源码进行编译,bazel的版本必须是在0.29.1及以下的。下载地址:https://github.com/bazelbuild/bazel/releases/download/0.29.1/bazel-0.29.1-installer-linux-x86_64.sh
bazel安装
执行以下命令:
sudo chmod +x bazel-0.29.1-installer-linux-x86_64.sh
./bazel-0.29.1-installer-linux-x86_64.sh --user
vim ~/.bashrc
# 在末尾添加下面内容
# export PATH="$PATH:$HOME/bin"
source ~./bashrc
编译tensorflow2.1.0-RC1
解压源码的压缩包。
进入解压后的文件夹。执行./configure
# 选择python的目录
Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3.6
# 选择支持XLA JIT
Do you wish to build TensorFlow with XLA JIT support? [Y/n]: Y
Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: N
Do you wish to bu