win10中tensorflow-gpu安装

本机安装的版本号如下

操作系统:           Windows10    
GPU型号:           NVIDIA GeForce 920MX
TensorFlow版本:tensorflow-gpu 1.9.0
CUDA版本:        cuda_9.0.176_win10
CUDNN版本:     cudnn-9.0-windows10-x64-v7.1

安装python的tensorflow使用gpu加速计算,

第一步,检查显卡型号是否支持cuda tookit,可在NVIDIA的网站上查询 https://developer.nvidia.com/cuda-gpus

win10中tensorflow-gpu安装_第1张图片

 

第二步,再发现显卡支持CUDA后,检查显卡驱动程序版本号是否到达Compute Capability要求的Version

若版本过低,会出现  CUDA driver version is insufficient for CUDA runtime version  错误提示,更新驱动程序

https://www.nvidia.com/Download/index.aspx?lang=en-us

win10中tensorflow-gpu安装_第2张图片

 

第三步,安装tensorflow-gpu包时,检查核对tensorflow-gpu版本所要求的CUDA版本号,否则依然回报错误异常

本次安装的tensorflow-gpu1.9.0 对应的CUDA版本为V9.0 ,下载https://developer.nvidia.com/cuda-toolkit-archive,

以及下载CUDAV9.0对应的CUDNN版本(须注册下载) https://developer.nvidia.com/rdp/cudnn-download

win10中tensorflow-gpu安装_第3张图片

对cuda_9.0安装完成之后,解压cudnn-9.0将其中目录直接复制到cuda根目录中进行添加复制(非覆盖)

 

第四步,安装tensorflow-gpu, pip install  tensorflow-gpu, 命令安装超时失败时可以下载安装包进行安装https://pypi.org/project/tensorflow-gpu/#history

 

第五步,最后一步进行验证,使用经典的hello world进行验证

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, World!')
>>> sess = tf.Session()
2018-07-25 11:12:06.628489: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2018-07-25 11:12:07.601675: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1392] Found device 0 with properties:
name: GeForce 920MX major: 5 minor: 0 memoryClockRate(GHz): 0.993
pciBusID: 0000:01:00.0
totalMemory: 2.00GiB freeMemory: 1.65GiB
2018-07-25 11:12:07.639248: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1471] Adding visible gpu devices: 0
2018-07-25 11:12:10.037604: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:952] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-07-25 11:12:10.049091: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:958]      0
2018-07-25 11:12:10.054498: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:971] 0:   N
2018-07-25 11:12:10.064852: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1084] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1418 MB memory) -> physical GPU (device: 0, name: GeForce 920MX, pci bus id: 0000:01:00.0, compute capability: 5.0)
>>> print(sess.run(hello))
b'Hello, World!'
>>>

 

 

你可能感兴趣的:(python/R,机器学习/算法)