1,关于tensorflow-gpu

https://www.python.org/downloads/windows/

版本需要特别的说明。

要不然安装会有问题。

首先,python不能是最新的版本,tensorflow 的升级速度还是跟不上python。

毕竟lib库很大,需要测试呢。

python 3.6 x64 的版本,3.7 不支持。

tensorflow 直接 pip 安装就行了。tensorflow-gpu-1.9.0

需要安装cuda lib,这个也要求是 64 - 9.0 版本

2,python-64-3.6 安装

安装的时候,选择自定义安装,需要安装到d盘。

因为安装lib啥的特别多,慢慢就把c 盘撑爆了。

安装第一步勾选上,【设置环境变量】,就可以了。

要是没有勾选,手动设置path到

d:pythonpython36;D:PythonPython36Scripts

目录是:d:pythonpython36

再自己的主目录 如:c:/user/admin 增加文件 pip/pip.ini

内容:

[global]

index-url = https://mirrors.aliyun.com/pypi/simple/

然后安装的资源就都走阿里啦,超级快,安装中好多问题都是网络问题。

使用ali的镜像,基本上没有啥问题了。

3,安装tensorflow-gpu

pip3 install tensorflow-gpu

运行报错:没有cuda:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "", line 1, in

File "D:PythonPython36libsite-packagestensorflow__init__.py", line 22, in

from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import

File "D:PythonPython36libsite-packagestensorflowpython__init__.py", line 49, in

from tensorflow.python import pywrap_tensorflow

File "D:PythonPython36libsite-packagestensorflowpythonpywrap_tensorflow.py", line 30, in

self_check.preload_check()

File "D:PythonPython36libsite-packagestensorflowpythonplatformself_check.py", line 82, in preload_check

% (build_info.cudart_dll_name, build_info.cuda_version_number))

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-toolkit

4,安装cuda

这里必须安装9.0 的版本,选择本地exe,这个网络国内还是不太好。

1.3 G。

里面包括了nvidia 的开发全家桶。

需要 visual studio ide 编译有些包,可以忽略。

还是报错:

Traceback (most recent call last):

File "", line 1, in

File "D:PythonPython36libsite-packagestensorflow__init__.py", line 22, in

from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import

File "D:PythonPython36libsite-packagestensorflowpython__init__.py", line 49, in

from tensorflow.python import pywrap_tensorflow

File "D:PythonPython36libsite-packagestensorflowpythonpywrap_tensorflow.py", line 30, in

self_check.preload_check()

File "D:PythonPython36libsite-packagestensorflowpythonplatformself_check.py", line 97, in preload_check

% (build_info.cudnn_dll_name, build_info.cudnn_version_number))

ImportError: Could not find 'cudnn64_7.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Note that installing cuDNN is a separate step from installing CUDA, and this DLL is often found in a different directory from the CUDA DLLs. You may install the necessary DLL by downloading cuDNN 7 from this URL: https://developer.nvidia.com/cudnn

下载是个zip 文件夹,把相关dll 拷贝到bin目录 lib 目录就行。

-Copy cudabincudnn64_7.dll to d:Program FilesNVIDIA GPU Computing ToolkitCUDAv9.0bin

-Copy cudaincludecudnn.h to d:Program FilesNVIDIA GPU Computing ToolkitCUDAv9.0include

-Copy cudalibx64cudnn.lib to d:Program FilesNVIDIA GPU Computing ToolkitCUDAv9.0libx64

然后就都安装成功了:

以后再windows 上面也可以使用gpu 进行运算了,加快训练速度。

4,总结

主要安装就是需要确定版本的问题。

使用python3.5 x64 使用 pip 安装 tensorflow-gpu

需要安装 cuda 9.0 x64

解压缩 cudnn 到 相应的 bin lib 目录。

然后就可以了,版本一定要一一对应才行。

下一步看看gpu的效果。

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐