Windows下Anaconda环境安装Tensorflow

朴灿烈づ我的快乐病毒、 2022-06-09 05:37 440阅读 0赞
  1. 安装好Anaconda后请确保以下几个路径已经添加到Window系统环境变量的path中

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

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

C:\ProgramData\Anaconda3\Library\bin

  1. 如下步骤,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 ‘ 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:

  1. cudatoolkit: 8.0-1 anaconda
  2. cudnn: 6.0-0 anaconda
  3. libprotobuf: 3.2.0-vc14\_0 anaconda \[vc14\]
  4. mkl: 2017.0.3-0 anaconda
  5. numpy: 1.12.1-py36\_0 anaconda
  6. pip: 9.0.1-py36\_1 anaconda
  7. protobuf: 3.2.0-py36\_0 anaconda
  8. python: 3.6.2-0 anaconda
  9. setuptools: 27.2.0-py36\_1 anaconda
  10. six: 1.10.0-py36\_0 anaconda
  11. tensorflow-gpu: 1.1.0-np112py36\_0 anaconda
  12. vs2015\_runtime: 14.0.25420-0 anaconda
  13. werkzeug: 0.12.2-py36\_0 anaconda
  14. wheel: 0.29.0-py36\_0 anaconda
  15. 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

输入如下代码

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

发表评论

表情:
评论列表 (有 0 条评论,440人围观)

还没有评论,来说两句吧...

相关阅读

    相关 anaconda 安装tensorflow & keras

      首先,同胞们要记住,你要做什么?该怎么做?你的目标是什么?千万不要因为中间遇到的连带问题,而忘记了你要做什么?一下开始介绍:   ? ? ? ? 下载:官网速度很慢,容易