Linux 下 anaconda安装tensorflow

下载与安装

你可以使用我们提供的 Pip, Docker, Virtualenv, Anaconda 或 源码编译的方法安装 TensorFlow.

极客学院团队出品

http://wiki.jikexueyuan.com/project/tensorflow-zh/get_started/os_setup.html

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

转载博客1:【深度学习】Ubuntu16.04+Anaconda安装+换源+环境创建+tensorflow安装(3)

https://blog.csdn.net/luojie140/article/details/78696330

转载博客2:Ubuntu安装Tensorflow及anaconda环境下使用TensorFlow

https://blog.csdn.net/piaoxuezhong/article/details/78897522

电脑环境:Ubuntu16.04,64位;anaconda最新版
(一)ubuntu-64位安装tensorflow过程:
1安装Anaconda
下载地址:https://www.continuum.io/downloads/(清华大学开源软件镜像站 https://mirror.tuna.tsinghua.edu.cn/)(我安装的是linux-64-python3.6)
然后执行:bash Anaconda×××-Linux-x86_64.sh ,然后一直enter键,中途会遇到([y]/n)? 的提示,输入y即可。
安装好后,在终端输入Python即可看见:Python 3.6.3 |Anaconda, Inc.|,表明安装成功。
2安装tensorflow(cpu版)

官方的建议是即时你有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
或者https://pypi.org/

下载之后,将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

3验证安装

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

(二)spyder使用tensorflow:
第三步验证成功,但spyder调用import tensorflow时出现报错:没有tensorflow模块。试过的解决方案(不晓得哪步起作用了,反正最后可以用了):
1.在tensorflow环境下,在终端用conda重新安装spyder。输入命令:
conda install spyder
2.将Spyder--tools--Python interpreter中改为TensorFlow目录下bin中的Python3.6
3.将/anaconda3/envs/tensorflow/lib/python3.6/site-packages下的所有文件都拷到anaconda3/lib/python3.5/site-packages下
(三)conda方式使用TensorFlow方法:
每次使用前,首先激活conda环境:

$ source activate tensorflow  

从conda环境中退出:

(tensorflow)$ source deactivate   
 

猜你喜欢

转载自blog.csdn.net/weixin_41078740/article/details/84062186