Windows下Anaconda环境安装Tensorflow

1. 安装好Anaconda后请确保以下几个路径已经添加到Window系统环境变量的path中

C:\ProgramData\Anaconda3      //C:\ProgramData\Anaconda3是我安装Anaconda的路径

C:\ProgramData\Anaconda3\Scripts        //Anaconda路径的Scripts子文件夹

 

C:\ProgramData\Anaconda3\Library\bin

 

 

2. 如下步骤,conda会帮你安装好所有相关软件包,本方法适合网速较快的朋友,如果网速较慢,建议直接用另一种方法3

C:\>conda create -n tensorflow

C:\>activate tensorflow

(tensorflow) C:\>python -m pip install --upgrade pip
Requirement already up-to-date: pip in c:\programdata\anaconda3\lib\site-packages

(tensorflow) C:\>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
     SmartAg/tensorflow_gpu    |    1.0.1 | conda           | linux-aarch64
     acellera/tensorflow-cuda  |   0.12.1 | conda           | linux-64
     anaconda/tensorflow       |    1.2.1 | conda           | linux-ppc64le, linux-64, osx-64, win-64
                                          : TensorFlow is a machine learning library
     anaconda/tensorflow-gpu   |    1.2.1 | conda           | linux-ppc64le, linux-64, win-64
                                          : TensorFlow is a machine learning library
     conda-forge/r-tensorflow  |      0.7 | conda           | linux-64, osx-64, win-64
     conda-forge/tensorflow    |    1.2.1 | 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        |    1.2.1 | conda           | osx-64
                                          : TensorFlow helps the tensors flow
     dhirschfeld/tensorflow    |    1.2.0 | conda           | win-64
                                          : Computation using data flow graphs for scalable machine learning
     dseuss/tensorflow         |          | conda           | osx-64
     guyanhua/tensorflow       |    1.0.0 | conda           | linux-64
     ijstokes/tensorflow       | 2017.03.03.1349 | conda, ipynb    | linux-64
     intel/tensorflow          |    1.2.1 | pypi, conda     | linux-64
     jjh_cio_testing/tensorflow |    1.2.0 | conda           | linux-64
                                          : TensorFlow is a machine learning library
     jjh_cio_testing/tensorflow-gpu |    1.2.1 | conda           | linux-64
                                          : TensorFlow is a machine learning library
     jjh_ppc64le/tensorflow    |    1.2.1 | conda           | linux-ppc64le
                                          : TensorFlow is a machine learning library
     jjh_ppc64le/tensorflow-gpu |    1.2.1 | conda           | linux-ppc64le
                                          : TensorFlow is a machine learning library
     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
     marta-sd/tensorflow       |    1.2.0 | conda           | linux-64
     marta-sd/tensorflow-gpu   |    1.2.0 | conda           | linux-64
     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
     nehaljwani/tensorflow     |    1.2.1 | conda           | osx-64, win-64
                                          : TensorFlow is a machine learning library
     nehaljwani/tensorflow-gpu |    1.1.0 | conda           | win-64
                                          : TensorFlow is a machine learning library
     r/r-tensorflow            |    0.8.2 | conda           | linux-64, win-32, win-64, linux-32, osx-64
                                          : Interface to TensorFlow
     rdonnelly/tensorflow      |    0.9.0 | conda           | linux-64
     rdonnellyr/r-tensorflow   |    0.4.0 | conda           | linux-64
     test_org_002/tensorflow   | 0.10.0rc0 | conda           |
     thomasantony/tensorflow_gpu |    1.0.1 | conda           | linux-aarch64
Found 39 packages


(tensorflow) C:\>anaconda show  anaconda/tensorflow-gpu
Using Anaconda API: https://api.anaconda.org
Name:    tensorflow-gpu
Summary: TensorFlow is a machine learning library
Access:  public
Package Types:  conda
Versions:
   + 1.0.1
   + 1.1.0
   + 1.2.1


To install this package with conda run:
     conda install --channel https://conda.anaconda.org/anaconda tensorflow-gpu


//选择安装最新GPU版本,你也可以选择安装CPU版, 国内连接这个网站比较慢,也可以用清华大学镜像网站

/*

//可以配置清华大学镜像网址

(tensorflow) C:\>conda config --addchannels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ 

(tensorflow) C:\>conda config --setshow_channel_urls yes

(tensorflow) C:\>conda install --channel hhttps://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/  tensorflow-gpu

//

*/

 

//用anaconda主机下载,可能比较慢
(tensorflow) C:\>conda install --channel https://conda.anaconda.org/anaconda tensorflow-gpu
Fetching package metadata .............
Solving package specifications: .


The following NEW packages will be INSTALLED:


    cudatoolkit:    8.0-1             anaconda
    cudnn:          6.0-0             anaconda
    libprotobuf:    3.2.0-vc14_0      anaconda [vc14]
    mkl:            2017.0.3-0        anaconda
    numpy:          1.12.1-py36_0     anaconda
    pip:            9.0.1-py36_1      anaconda
    protobuf:       3.2.0-py36_0      anaconda
    python:         3.6.2-0           anaconda
    setuptools:     27.2.0-py36_1     anaconda
    six:            1.10.0-py36_0     anaconda
    tensorflow-gpu: 1.1.0-np112py36_0 anaconda
    vs2015_runtime: 14.0.25420-0      anaconda
    werkzeug:       0.12.2-py36_0     anaconda
    wheel:          0.29.0-py36_0     anaconda
    zlib:           1.2.11-vc14_0     anaconda [vc14]


Proceed ([y]/n)? y

等待.................................


另一种方法:

3  安装CPU版本请跳过3.1 3.2 3.3

下载 3.1 3.2

3.1

CUDA® Toolkit 8.0. For details, see NVIDIA's documentation 

3.2   需要用邮箱注册成Nvdia开发者下载,最好用国外邮箱,国内有些邮箱可能收不到激活邮件。

注意现在tensorflow还不支持最新的cuDNN7.0, 一定要下载cuDNN V6.0 for cuda8.0

cuDNN v6 or v6.1. For details, see NVIDIA's documentation

 

3.3

安装完3.1后,确认cuda toolkit的路径已经在系统环境变量path中,不在请手动添加 toolkit的安装路径 如C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0到系统环境变量

将3.2文件解压后的三个文件夹拷贝到C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0

 

3.4

cmd指令窗口运行

C:\>conda create -n tensorflow
C:\>activate tensorflow

//安装CPU版本用这个指令

(tensorflow) C:\>pip install --ignore-installed --upgrade tensorflow

 

//如果安装GPU版本用这个指令

(tensorflow) C:\pip install --ignore-installed --upgrade tensorflow-gpu

 

 

4 确认tensorflow正确安装

 

 

C:\>python

输入如下代码

 


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

 

当看到如下打印,即正确安装了

b'Hello, TensorFlow!'
>>>

 

No module pip* 解决方法

(tensorflow) C:\WINDOWS\system32>python -m ensurepip

(tensorflow) C:\WINDOWS\system32>easy_install pip==18.1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值