由于之前在虚拟机 centos7安装cuda7失败,虚拟显卡繁琐又效果又不好,打算只在虚拟机用CPU的tensorflow,
GPU的在window 7下安装。
这篇博文主要是虚拟机centos7中cpu的tensorflow的使用。
参考官网安装文档
git clone https://github.com/bazelbuild/bazel.git
cd bazel
git checkout tags/0.1.0
./compile.sh
git clone --recurse-submodules https://github.com/tensorflow/tensorflow
cd tensorflow
./configure
提示:Cannot find bazel. Please install bazel
接下来配置路径
export PATH=$PATH:bazel所在绝对路径/output/bazel
./configure
Do you wish to build TensorFlow with MPI support?[y/N]:y
MPI support will be enabled for Tensorflow.
Please specify the MPI toolkit folder.[Default is]: /usr
然后出现如下提示,就退出了
Traceback (most recent call last):
File "configure.py", line 1337, in
main()
File "configure.py", line 1308, in main
set_other_mpi_vars(environ_cp)
File "configure.py", line 1205, in set_other_mpi_vars
raise ValueError('Cannot find the MPI library file in %s/lib' % mpi_home)
ValueError: Cannot find the MPI library file in /usr/lib
再执行./configure
出现
Unexpected error reading .blazerc file '%workspace%/.tf_configure.bazelrc'
Traceback (most recent call last):
File "configure.py", line 1337, in
main()
File "configure.py", line 1232, in main
check_bazel_version('0.5.4')
File "configure.py", line 458, in check_bazel_version
curr_version = run_shell(['bazel', '--batch', 'version'])
File "configure.py", line 153, in run_shell
output = subprocess.check_output(cmd)
File "/usr/lib64/python2.7/subprocess.py", line 575, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['bazel', '--batch', 'version']' returned non-zero exit status 37
然后把下载的tensorflow删除,重启centos7,运行命令
sudo yum install python-numpy swig python-dev
再把上边那些命令运行了一遍,配置完成
编译参考这篇http://blog.csdn.net/mafeiyu80/article/details/51397795
运行
bazel build -c opt --jobs 1 //tensorflow/cc:tutorials_example_trainer
出现错误
Unexpected error reading .blazerc file '%workspace%/.tf_configure.bazelrc'
然后用.tf_configure.bazelrc文件所在目录,也就是当前tensorflow目录,绝对路径替换%workspace%
再执行,出现问题
Unrecognized option: --action_env
之后多次尝试,发现bazel版本不是最新,下载最新源码git checkout tags/0.9.0
安装之后
再配置,编译tensorflow就好了
参考博文
Centos7编译安装tensorflow1.3(cpu版)
https://weibo.com/ttarticle/p/show?id=2313501000014150567604755607
http://blog.csdn.net/lixiaowei16/article/details/75125973
在linux(centos)上从源码安装tensorflow
http://blog.csdn.net/mafeiyu80/article/details/51397795
安装tensorflow,那叫一个坑啊
https://www.cnblogs.com/shihuc/p/6593041.html
Linux CentOS 7 下 JDK 1.7 安装与配置
http://www.linuxidc.com/Linux/2016-09/135556.htm
http://www.linuxidc.com/Linux/2016-09/134941.htm