windows 下 Anaconda 安装 TensorFlow
2018-03-12 16:23
323 查看
转至http://www.cnblogs.com/nosqlcoco/p/6923861.html
另外一个连接:https://blog.csdn.net/darlingwood2013/article/details/60322258什么是 Anaconda?
Anaconda is the leading open data science platform powered by Python.
Anaconda 是一个由 Python 语言编写领先的开放数据科学平台什么是 TensorFlow?TensorFlow is an open source software library for numerical computation using data flow graphs.
TensorFlow是一个开源软件库,用于使用数据流图进行数值计算。TensorFlow r0.12 及以后版本添加了对 windows 系统的支持,自此实现了三大平台,一套代码多平台运行。安装 TensorFlow 方式有很多种,下面使用 Anaconda 在 windows10 安装 TensorFlow (CPU版)。1. 下载 Anaconda在 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 寻找你与你电脑系统对应的版本,我这里使用 Anaconda3-4.2.0-Windows-x86_64.exe
你也可以打开 https://mirrors.tuna.tsinghua.edu.cn/tensorflow/ 选择合适的 whl 文件地址进行安装;或者打开https://mirrors.tuna.tsinghua.edu.cn/help/tensorflow/ 可视化选择 whl 版本。
目前 API 变动比较大,例如tf.mul、tf.sub 和 tf.neg 被弃用,现在使用的是 tf.multiply、tf.subtract 和 tf.negative. 使用不当会输出 AttributeError: module 'tensorflow' has no attribute 'mul' 等错误,需要我们经常 github 上查看更新日志。
另外一个连接:https://blog.csdn.net/darlingwood2013/article/details/60322258什么是 Anaconda?
Anaconda is the leading open data science platform powered by Python.
Anaconda 是一个由 Python 语言编写领先的开放数据科学平台什么是 TensorFlow?TensorFlow is an open source software library for numerical computation using data flow graphs.
TensorFlow是一个开源软件库,用于使用数据流图进行数值计算。TensorFlow r0.12 及以后版本添加了对 windows 系统的支持,自此实现了三大平台,一套代码多平台运行。安装 TensorFlow 方式有很多种,下面使用 Anaconda 在 windows10 安装 TensorFlow (CPU版)。1. 下载 Anaconda在 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 寻找你与你电脑系统对应的版本,我这里使用 Anaconda3-4.2.0-Windows-x86_64.exe
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-4.2.0-Windows-x86_64.exe下载并安装完成后,打开 CMD, 输入 'conda --version', 如果输出如下信息
conda 4.2.0Anaconda 安装成功。接下来需要设置 Anaconda 仓库镜像,因为默认连接的是国外镜像地址,下载速度比较慢,我们把镜像地址改为清华大学开源软件镜像站,打开 Anaconda Prompt, 输入:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --set show_channel_urls yes
2.安装 TensorFlow
继续在 Anaconda Prompt 窗口输入:conda create -n tensorflow python=3.5按回车。表示创建 TensorFlow 依赖环境,TensorFlow 目前不支持Python3.6,这里我们使用Python3.5。继续看控制台输出:
Fetching package metadata ............... Solving package specifications: . Package plan for< 4000 /span> installation in environment D:\Program Files\anaconda\envs\tensorflow: The following NEW packages will be INSTALLED: pip: 9.0.1-py35_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free python: 3.5.3-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free setuptools: 27.2.0-py35_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free vs2015_runtime: 14.0.25123-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free wheel: 0.29.0-py35_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free Proceed ([y]/n)? y提示我们安装哪些依赖软件,输入‘y’,回车。控制台继续输出:
python-3.5.3-0 100% |###############################| Time: 0:00:42 754.91 kB/s setuptools-27. 100% |###############################| Time: 0:00:00 1.92 MB/s wheel-0.29.0-p 100% |###############################| Time: 0:00:00 2.68 MB/s pip-9.0.1-py35 100% |###############################| Time: 0:00:00 2.31 MB/s # # To activate this environment, use: # > activate tensorflow # # To deactivate this environment, use: # > deactivate tensorflow # # * for power-users using bash, you must source #开始下载安装依赖软件,我这里使用的是清华大学镜像仓库,所以下载速度很快。安装 CPU 版本:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ https://mirrors.tuna.tsinghua.edu.cn/tensorflow/windows/cpu/tensorflow-1.1.0-cp35-cp35m-win_amd64.whl如果控制台最终输出 如下信息表示安装成功。
你也可以打开 https://mirrors.tuna.tsinghua.edu.cn/tensorflow/ 选择合适的 whl 文件地址进行安装;或者打开https://mirrors.tuna.tsinghua.edu.cn/help/tensorflow/ 可视化选择 whl 版本。
Successfully installed numpy-1.12.1 protobuf-3.3.0 six-1.10.0 tensorflow-1.1.0 werkzeug-0.12.2继续输入:
activate tensorflow激活 TensorFlow 虚拟环境,当不使用 TensorFlow 时,使用 deactivate tensorflow 关闭。
3.测试
进入到 Anaconda 安装目录下 /envs /tensorflow 文件夹,继续在 Anaconda Prompt 窗口输入输入:python.exe回车后,复制复制如下内容拷贝到Anaconda Prompt,自动输出:
import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() >>> sess.run(hello) >>> a = tf.constant(10) >>> b= tf.constant(32) >>> sess.run(a+b) >>>输出:
... b'Hello, TensorFlow!' ... 42表示 TensorFlow 已经安装成功。
4.有些坑
如果使用 py 文件编写tensorflow 脚本,文件名不能使用 tensorflow.py目前 API 变动比较大,例如tf.mul、tf.sub 和 tf.neg 被弃用,现在使用的是 tf.multiply、tf.subtract 和 tf.negative. 使用不当会输出 AttributeError: module 'tensorflow' has no attribute 'mul' 等错误,需要我们经常 github 上查看更新日志。
相关文章推荐
- TensorFlow版本升级方法【之前通过Anaconda安装】(Windows)
- Windows下利用Anaconda安装多个版本的TensorFlow
- 在windows Anaconda中安装tensorflow 以及spyder 插件
- windows下安装Anaconda及tensorflow
- Windows下用Anaconda安装TensorFlow
- Windows环境下用Anaconda(2.7/3.6)安装GPU版TensorFlow
- 【TensorFlow】Windows+Anaconda3+Tensorflow(CPU&GPU)+Pycharm 安装
- windows上基于anaconda安装tensorflow
- Windows下Anaconda中安装tensorflow
- Windows下用Anaconda安装TensorFlow,并在pycharm中使用
- windows如何安装anaconda发行版的python以及tensorflow的安装
- windows Anaconda安装tensorflow出现的一些问题
- 环境搭建—Windows10下Anaconda3安装tensorflow,theano,keras,pytorch以及为keras切换不同的后端
- windows 下 Anaconda 安装 TensorFlow
- 【深度学习】windows下使用anaconda安装TensorFlow
- 在windows Anaconda中安装tensorflow 以及spyder 插件
- 170614 Windows10+Anaconda2/3+tensorflow-1.2.0rc2(cpu & gpu) 安装
- 基于Anaconda的TensorFlow安装,Windows,Linux,Ubuntu
- Windows环境下(64bit,内存4G),安装虚拟机(VM12.5),Ubuntu(17.04),anaconda(Python3.6)和TensorFlow(1.3)