TensorFlow 安装
预先安装
- Centos 7
- Anaconda3-5.2
还有一点,TensorFlow在安装过程中,环境需要联网,不然无法完成。
在线安装
可以访问清华镜像官网,寻找适合自己平台的资源。
https://mirrors.tuna.tsinghua.edu.cn/help/tensorflow/
我选择的是安装1.7.0版本的tensorflow,生成的链接 :
https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/tensorflow-1.7.0-cp36-cp36m-linux_x86_64.whl
使用下面的命令安装: pip install \
-i https://pypi.tuna.tsinghua.edu.cn/simple/ \
https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/tensorflow-1.7.0-cp36-cp36m-linux_x86_64.whl
离线安装
在我安装第二台机器的时候,清华镜像网站访问无法访问,于是采用离线安装。
访问网站 https://pypi.org/project/tensorflow/ , 在Release history中寻找适合自己的版本,我选择的是1.5.0版本。
下载好的tensorflow安装包,大约43M。
测试tensorflow
python
import tensorflow as tf
如果没有报错,就说明安装完成。
问题1:AttributeError: module ‘pandas’ has no attribute ‘core’
这里的pandas版本与tensorflow不兼容,可以通过重装pandas的方式解决:
卸载pandas ,大约1秒完成 pip uninstall pandas
重新安装pandas,大约9M,可能需要一点时间 pip install pandas
问题2:FutureWarning: Conversion of the second argument of issubdtype from float
to np.floating
is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type
.
安装完成以后,发现一个警告 FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
这只是一个警告,不影响使用,可以通过更改tensorflow的日志级别,控制这些信息不显示。 import os
os.environ["TF_CPP_MIN_LOG_LEVEL"]="3"
但是,更合理的方式应该是采用下面的解决方案:
pip install h5py==2.8.0rc1
再实验一下,没有错误,终于安装完成: