Ubuntu16.04基于Anaconda(py3.6)安装TensorFlow(CPU)的方法

安装tensorflow(cpu版)

对anaconda命令的熟悉,可以参考http://www.jianshu.com/p/d2e15200ee9b 
官方的建议是即时你有gpu,但也可以先装一个cpu版,创建环境的命令为:

conda create -n tensorflow python=3.6 
(一定要指定python版本,我一开始没有写python=3.6,后面各种失败)

先下载安装包,下载路径为:https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.0-cp36-cp36m-linux_x86_64.whl 
下载之后,将whl文件重命名为tensorflow-1.0.0-py3-none-linux_x86_64.whl,否则会出现

tensorflow-1.0.0-cp36-cp36m-linux_x86_64.whl is not a supported wheel on this platform一样的报错,具体参考https://github.com/tensorflow/tensorflow/issues/1990 
然后进入环境并安装tensorflow

source activate tensorflow #激活tensorflow环境

cd /Downloads #切换到whl文件所在文件夹

pip install --ignore-installed --upgrade tensorflow-1.0.0-py3-none-linux_x86_64.whl #切记,不要用sudo pip,也不要用pip3,然后--ignore-installed --upgrade等参数也不能省略,否则会出错。

此处来源:http://blog.csdn.net/michaelliang12/article/details/60106686

验证安装

成功。

(tensorflow)$ python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
sess.run(hello)

存在的问题,运行时,两个版本均有warning, NOT error,但是不影响结果,只是执行速度比较慢,据说是因为为了不同框架上的可迁移性,还没有对cpu进行编译,他建议你为了更快的速度,可以从编码编译,执行速度会更快。

但是此时发现在spyder或者pycharm中  使用TensorFlow无法识别。

打开你的anaconda文件夹,找到envs 打开tensorflow 将sitepack-ages里面的东西都考到 anaconda/lib/python2.7/sitepack-ages
此时再使用spyder pycharm便可以导入tensorflow了
来源:http://blog.csdn.net/zzw000000/article/details/51203331
posted @ 2017-08-03 18:35  诗恩胜  阅读(7854)  评论(0编辑  收藏  举报