windows anaconda 下安装tensorflow

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.0

Anaconda 安装成功。

接下来需要设置 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 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

如果这个版本太低可选择新版本

在终端或cmd中输入以下命令搜索当前可用的tensorflow版本

$ anaconda search -t conda tensorflow

Using Anaconda API: https://api.anaconda.org
Run 'anaconda show <USER/PACKAGE>' to get more details:
Packages:
     Name                      |  Version | Package Types   | Platforms      
     ------------------------- |   ------ | --------------- | ---------------
     HCC/tensorflow            |    1.0.0 | conda           | linux-64       
     HCC/tensorflow-cpucompat  |    1.0.0 | conda           | linux-64       
     HCC/tensorflow-fma        |    1.0.0 | conda           | linux-64       
     SentientPrime/tensorflow  |    0.6.0 | conda           | osx-64         
                                          : TensorFlow helps the tensors flow
     acellera/tensorflow-cuda  |   0.12.1 | conda           | linux-64       
     anaconda/tensorflow       |    1.0.1 | conda           | linux-64       
     anaconda/tensorflow-gpu   |    1.0.1 | conda           | linux-64       
     conda-forge/tensorflow    |    1.0.0 | conda           | linux-64, win-64, osx-64
                                          : TensorFlow helps the tensors flow
     creditx/tensorflow        |    0.9.0 | conda           | linux-64       
                                          : TensorFlow helps the tensors flow
     derickl/tensorflow        |   0.12.1 | conda           | osx-64         
     dhirschfeld/tensorflow    | 0.12.0rc0 | conda           | win-64         
     dseuss/tensorflow         |          | conda           | osx-64         
     guyanhua/tensorflow       |    1.0.0 | conda           | linux-64       
     ijstokes/tensorflow       | 2017.03.03.1349 | conda, ipynb    | linux-64       
     jjh_cio_testing/tensorflow |    1.0.1 | conda           | linux-64       
     jjh_cio_testing/tensorflow-gpu |    1.0.1 | conda           | linux-64       
     jjh_ppc64le/tensorflow    |    1.0.1 | conda           | linux-ppc64le  
     jjh_ppc64le/tensorflow-gpu |    1.0.1 | conda           | linux-ppc64le  
     jjhelmus/tensorflow       | 0.12.0rc0 | conda, pypi     | linux-64, osx-64
                                          : TensorFlow helps the tensors flow
     jjhelmus/tensorflow-gpu   |    1.0.1 | conda           | linux-64       
     kevin-keraudren/tensorflow |    0.9.0 | conda           | linux-64       
     lcls-rhel7/tensorflow     |   0.12.1 | conda           | linux-64       
     marta-sd/tensorflow       |    1.0.1 | conda           | linux-64       
                                          : TensorFlow helps the tensors flow
     memex/tensorflow          |    0.5.0 | conda           | linux-64, osx-64
                                          : TensorFlow helps the tensors flow
     mhworth/tensorflow        |    0.7.1 | conda           | osx-64         
                                          : TensorFlow helps the tensors flow
     miovision/tensorflow      | 0.10.0.gpu | conda           | linux-64, osx-64
     msarahan/tensorflow       | 1.0.0rc2 | conda           | linux-64       
     mutirri/tensorflow        | 0.10.0rc0 | conda           | linux-64       
     mwojcikowski/tensorflow   |    1.0.1 | conda           | linux-64       
     rdonnelly/tensorflow      |    0.9.0 | conda           | linux-64       
     rdonnellyr/r-tensorflow   |    0.4.0 | conda           | osx-64         
     test_org_002/tensorflow   | 0.10.0rc0 | conda           |                
Found 32 packages

选择一个较新的CPU或GPU版本,如jjh_cio_testing/tensorflow-gpu的1.0.1版本,输入如下安装命令

$ conda install --channel https://conda.anaconda.org/jjh_cio_testing tensorflow

Fetching package metadata .............
Solving package specifications: .

Package plan for installation in environment /home/will/anaconda2:

The following packages will be SUPERSEDED by a higher-priority channel:

    tensorflow-gpu: 1.0.1-py27_4 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free --> 1.0.1-py27_4 jjh_cio_testing

Proceed ([y]/n)? 

conda会自动检测安装此版本的Tensorflow所依赖的库,如果你的Anaconda缺少这些依赖库,会提示你安装。因为我之前已经安装过了,所以这里只提示我安装Tensorflow。输入y并回车之后等待安装结束即可

  • 可以选择次高版本的Tensorflow安装,因为最新版本可能清华 TUNA的仓库镜像库没有及时更新,而官方更新连接总是失败,我最开始选择了jjhelmus/tensorflow-gpu的1.0.1版本,其他依赖库清华 TUNA的仓库镜像有资源,而到最后jjhelmus/tensorflow-gpu版本的Tensorflow安装包总是下载不下来,尝试20多次之后换了一个1.0.0的版本,终于顺利安装成功

进入python,输入

import tensorflow as tf

如果没有报错说明安装成功。

转自:https://www.cnblogs.com/nosqlcoco/p/6923861.html

http://www.cnblogs.com/willnote/p/6746499.html

 

posted @ 2018-07-28 20:58  AI_ON  阅读(230)  评论(0)    收藏  举报