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

xiaoxiao2021-02-28  126

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;filename="cudnn-8.0-windows10-x64-v5.1.zip"&OSSAccessKeyId=9q6nvzoJGowBj4q1&Expires=1493949956&Signature=LK5paj9E9v6VQNTrqfOZlrNJGkE=

 

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

转载请注明原文地址: https://www.6miu.com/read-22863.html

最新回复(0)