Ubuntu14.04虚拟机+anaconda3.5+python3.6+tensorflow配置

tensorflow已经成为最流行的深度学习框架,可能没有之一,VMware虚拟机可以实现CPU版本的tensorflow运行,在不需要进行大规模数据计算的情况下,能够胜任tensorflow的python调用。
vmware的ubuntu虚拟机自带python2.7和python3.4,但不建议卸载,有许多指令都与自带的python有关联,卸载会一并卸载掉。
事前安装好:
VMware 的ubuntu虚拟机

一、anaconda3.5安装

1.1 下载安装包
官网下载地址,清华镜像源下载地址
1.2 安装
将安装包移入Ubuntu虚拟机,运行指令

bash ./Anaconda3-5.2.0-Linux-x86_64.sh

注意最后一项选no
Ubuntu14.04虚拟机+anaconda3.5+python3.6+tensorflow配置_第1张图片
1.3使环境变量生效
安装过程中,会有一项提示,如果输入yes,则在安装结束后在命令行输入source ~/.bashrc使环境变量生效
Ubuntu14.04虚拟机+anaconda3.5+python3.6+tensorflow配置_第2张图片
如果错过了,如上图(安装过程没注意),可以在安装后,输入以下指令(将安装目录对应下的bin文件添加至~/.bashrc)

export PATH=/home/username/anaconda3/bin:$PATH

1.4检验
Linux的命令行中输入python --version
输出如下,表示安装成功
在这里插入图片描述

二、tensorflow安装

在Linux命令行中输入anaconda-navigator,直接在环境中搜索tensorflow,“apply”,简单粗暴!
Ubuntu14.04虚拟机+anaconda3.5+python3.6+tensorflow配置_第3张图片
Ubuntu14.04虚拟机+anaconda3.5+python3.6+tensorflow配置_第4张图片
不过这种方法还是略有欠缺,只能安装最新版本的tensorflow,建议使用下一种方法
2.1创建名为tensorflow的conda环境,对应你的python版本

conda create -n tensorflow python=3.6

Ubuntu14.04虚拟机+anaconda3.5+python3.6+tensorflow配置_第5张图片
2.2激活虚拟环境(好处是不会干扰虚拟机正常的环境变量)

source activate tensorflow

在这里插入图片描述
查看虚拟机现存的虚拟环境指令:conda info --envs
退出虚拟环境source deactivate

2.3安装TensorFlow到你的conda环境中
tensorflow的版本可自选,此处用的比较旧的版本1.4.1,正常可以安装2.1(不同版本下载地址参考[GPU版本] [CPU版本])

pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.4.1-cp36-cp36m-linux_x86_64.whl

在这里插入图片描述
2.4验证
输入python,输入import tensorflow,成功如下:

>>> import tensorflow
/home/username/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:469: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/username/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:470: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/username/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:471: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/username/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:472: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/username/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:473: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/username/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:476: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
/home/username/anaconda3/envs/tensorflow/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6
  return f(*args, **kwds)
>>> import tensorflow

参考文献
虚拟机下安装anaconda3+python3.6+TensorFlow

你可能感兴趣的:(Linux,python,anaconda,tensorflow,ubuntu)