win10+gtx1070+tensorflow+cuda8.0+cudn搭建深度学习环境

Win10+1070+cuda8.0+cudn-->TensorFlow的步骤:

 

 

亲测有效。

步骤

1、安装Anaconda 
直接在官网下载并安装Anaconda,这里选择64版本。 注意,windows下安装TensorFlow,要求python版本是3.5,64位。 

安装完Anaconda,也就安装了python3.5等相关工具

 

本人下载的是Python 3.5的anaconda:

https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-4.2.0-Windows-x86_64.exe

2、安装完成后,用管理员权限打开,否则会报错。打开Anaconda Prompt,创建TensorFlow虚拟环境 
Prompt中输入:

>>> conda create -n tensorflow python=3.5

更新的,全部设置为 y,进行更新。

3、进入TensorFlow环境,输入

>>> activate tensorflow

在命令行前,你就可以看到在输入提示符前加了(tensorflow) 
变成了这样:

tensorflow)...>>>

如果要退出该虚拟环境,输入 deactive tensorflow 即可

4 安装tensorflow

· gpu版本

pip install --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0-cp35-cp35m-win_amd64.whl

· cpu版本

pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0-cp35-cp35m-win_amd64.whl

如果安装出现问题:

     在安装tensorflow时出现 “Cannot remove entries from nonexistent file c:\program files\anaconda3\lib\site-packages\easy-install.pth” 的问题。查看原因是因为setuptools版本太低,tensorflow要求29.0.1,当前版本为27.2.0,在更新setuptools版本的时候又找不到easy-install.pth,导致更新失败

运行:pip install --upgrade --ignore-installed setuptools,问题解决!

一、Cpu版本到此结束,可以直接在导入TensorFlow实验。

 

二、gpu版本还需要安装两个文件。

安装cuda8.0

https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_win10-exe

下载cudnn5.1

http://dl.download.csdn.net/down11/20161115/4c31a7e5fa4af2e6a2097afccdf9d550.zip?response-content-disposition=attachment%3Bfilename%3D%22cudnn-8.0-windows10-x64-v5.1.zip%22&OSSAccessKeyId=9q6nvzoJGowBj4q1&Expires=1493949956&Signature=LK5paj9E9v6VQNTrqfOZlrNJGkE%3D

 

cuda8.0 安装好后,找到它的安装路径,找到相对应的目录。

 

 

 cudn文件解压里面有三个文件的三个小文本,补充到这个文件相对应的目录下。

将该文件的bin目录到PATH环境变量

 

TensorFlow 实验运行展示:

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
#Creates a session with log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
#Runs the op.
print (sess.run(c))
运行成功:

。。。。。//省略
MatMul: (MatMul): /job:localhost/replica:0/task:0/gpu:0
b: (Const): /job:localhost/replica:0/task:0/gpu:0
a: (Const): /job:localhost/replica:0/task:0/gpu:0
Const: (Const): /job:localhost/replica:0/task:0/cpu:0
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\simple_placer.cc:827] MatMul: (MatMul)/job:localhost/replica:0/task:0/gpu:0
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\simple_placer.cc:827] b: (Const)/job:localhost/replica:0/task:0/gpu:0
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\simple_placer.cc:827] a: (Const)/job:localhost/replica:0/task:0/gpu:0
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\simple_placer.cc:827] Const: (Const)/job:localhost/replica:0/task:0/cpu:0
[[ 22.  28.]
 [ 49.  64.]]



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值