Win10下Tensorflow(GPU版)安装趟坑实录,成功了。

这篇文章不指导你具体怎么安装,其他博客大把安装方法,我只告诉你,具体的版本不要看其他人的,每个人用的CUDA可能都不同,越看越乱,直接看运行后系统的提示,我整了一天没有搞定,最后还是按照系统提示搞定的。

Win10上搭建TensorFlow的开发环境需要至少需要安装3个软件,分别为:1.python,2.CUDA和CuDNN,3.TensorFlow(GPU版)。安装前一定要确认好每个软件的版本是否相互支持。


只要确保Python版本在3.5以上,CUDA的具体版本是由TensorFlow决定的,这点消息在TensorFlow官网可以看到,可惜大陆无法打开https://www.tensorflow.org/install/install_windows,所以具体的CUDA版本每个人意见都不同,才会看到如下的谆谆教诲:


下载安装Cuda8.0,一定要是8.0版本!下载地址,并按照下图选择下载本地安装包。 

另外一个博客的
1,CUDA Toolkit 9.0, 注意,版本一定要是V9.0,不能9.1,9.2...

2,对应CUDA toolkit 9.0的cuDNN v7.0

我自己从CUDA9.1,到CUDA8.0 都下载了,然后再删除了。最后根据提示才下载了CUDA9.0版本。

********************************************一下是错误报告和解决方案*************************************************

第一次运行错误:

OSError: [WinError 126] 找不到指定的模块。
ImportError: Could not find 'msvcp140.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. 
You may install this DLL by downloading Visual C++ 2015 Redistributable Update 3 from this URL: https://www.microsoft.com/en-us/download/details.aspx?id=53587
解决方案:
ImportError: Could not find 'msvcp140.dll'
这个问题按照提示去官网https://www.microsoft.com/en-us/download/details.aspx?id=53587下载Microsoft Visual C++ 2015 Redistributable Update 3搞定了

第二次运行:

但是运行后出现了新的问题:

OSError: [WinError 126] 找不到指定的模块。

ImportError: Could not find 'cudart64_90.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. 
Download and install CUDA 9.0 from this URL: https://developer.nvidia.com/cuda-90-download-archive

然后又按照网址下载CUDA,发现,哇直接是9.0的版本,我没有多考虑,直接下载安装,重启电脑,运行程序,成功了,好想抱抱自己,折腾了一天,总算搞定了。

总结我的版本:

Windows 10

GPU: NVIDIA geforce gtx 1050 ti 版本计算能力是    6.1,符合要求(3.0 or higher. )

Python 3.5.3

TensorFlow 1.10

CUDA 9.0 

cuDNN:cuDNN v7.2.1 Library for Windows 10 点击下载后文件是:cudnn-9.0-windows10-x64-v7.1.zip

运行一下程序测试:

import tensorflow as tf
a = tf.random_normal((100, 100))
b = tf.random_normal((100, 500))
c = tf.matmul(a, b)
sess = tf.InteractiveSession()

成功输出:

2018-08-23 21:34:46.199306: 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-08-23 21:34:46.451281: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1405] Found device 0 with properties: 
name: GeForce GTX 1050 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.4175
pciBusID: 0000:01:00.0
totalMemory: 4.00GiB freeMemory: 3.30GiB
2018-08-23 21:34:46.451897: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1484] Adding visible gpu devices: 0
2018-08-23 21:34:47.189717: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:965] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-08-23 21:34:47.190132: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:971]      0 
2018-08-23 21:34:47.190374: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:984] 0:   N 
2018-08-23 21:34:47.190729: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1097] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 3017 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1050 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)
[Finished in 2.6s]

猜你喜欢

转载自blog.csdn.net/BTUJACK/article/details/81988321