WIN10+RTX2070 tensorflow-gpu环境搭建

参考

tensorflow-windows-wheel 我选择了:1.12.0\py37\GPU\cuda100cudnn73sse2

前置环境

  • Visual Studio 2017
  • Anaconda3
这两个我都安装的最新版。
Visual Studio 2017不装会导致安装CUDA时"Visual Studio Integration"组件安装失败,我在此处卡了几天,查了好多资料都无效。

GPU相关软件下载

安装

  • 显卡驱动安装
  • 安装CUDA
安装好之后的环境变量默认包含:
CUDA_PATH:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0
CUDA_PATH_V10_0:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0
PATH:
	C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin
	C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\libnvvp
	C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\extras\CUPTI\libx64(这个需要自己添加)
  • 安装cuDNN
解压cuDNN后得到bin、include、lib三个文件夹
将bin下的cudnn64_7.dll拷贝到:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin
将include下的cudnn.h拷贝到:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\include
将lib\x64下的cudnn.lib拷贝到:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\lib\x64

tensorflow-gpu环境配置

  • 打开
  • 创建环境
    	conda create -n tensorflow_gpu_1.12_py37 python=3.7
    
  • 激活环境
    	conda activate tensorflow_gpu_1.12_py37
    
  • 安装tensorflow-gpu
    	pip install E:\Downloads\tensorflow_gpu-1.12.0-cp37-cp37m-win_amd64.whl
    
  • 测试
    	进入python
    	>>> import tensorflow as tf
    	>>> hello = tf.constant('Hello, tensorflow!')
    	>>> sess = tf.Session()
    
    输出:
    	2019-03-02 09:37:52.875467: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
    	2019-03-02 09:37:53.200917: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1432] Found device 0 with properties:name: GeForce RTX 2070 major: 7 minor: 5 memoryClockRate(GHz): 1.62
    	pciBusID: 0000:01:00.0
    	totalMemory: 8.00GiB freeMemory: 6.59GiB
    	2019-03-02 09:37:53.207587: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0
    	2019-03-02 09:40:52.845289: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix:
    	2019-03-02 09:40:52.848702: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988]      0
    	2019-03-02 09:40:52.850105: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0:   N
    	2019-03-02 09:40:52.854219: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow 
    	device (/job:localhost/replica:0/task:0/device:GPU:0 with 6331 MB memory) -> physical GPU (device: 0, 
    	name: GeForce RTX 2070, pci bus id: 0000:01:00.0, compute capability: 7.5)
    
    接着执行
    	print(sess.run(hello))
    
    输出:
    	b'Hello, tensorflow!'
    
    关闭session
    	sess.close()
    

至此结束,第一次感觉开发环境搭建不容易。

转载于:https://my.oschina.net/pasenger/blog/3016987

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值