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
在这里插入图片描述
1.3使环境变量生效
安装过程中,会有一项提示,如果输入yes,则在安装结束后在命令行输入source ~/.bashrc使环境变量生效
在这里插入图片描述
如果错过了,如上图(安装过程没注意),可以在安装后,输入以下指令(将安装目录对应下的bin文件添加至~/.bashrc)

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

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

二、tensorflow安装

在Linux命令行中输入anaconda-navigator,直接在环境中搜索tensorflow,“apply”,简单粗暴!
在这里插入图片描述
在这里插入图片描述
不过这种方法还是略有欠缺,只能安装最新版本的tensorflow,建议使用下一种方法
2.1创建名为tensorflow的conda环境,对应你的python版本

conda create -n tensorflow python=3.6

在这里插入图片描述
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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值