系统配置:Windows 7 x64
安装类型: tensorflow-gpu
CUDA: 8.0
cuDNN: 6.1
关于 CUDA 和 cuDNN 的安装请查看之前文章
tensorflow 官网有提供安装说明:https://www.tensorflow.org/versions/r1.3/install/install_windows
我是通过 pip 方式安装的,大概过程
一,安装 python3 和 pip3
1,下载安装包
python3 安装包中,包含了 pip3
下载地址:https://www.python.org/downloads/release/python-352/
下载完后直接点击安装即可,系统默认添加 PATH 路径
2,检查安装情况
C:\Users>python -V Python 3.5.3 C:\Users>pip3 -V pip 9.0.1 from d:\program files\python35\lib\site-packages (python 3.5)
二,安装 tensorflow-gpu
1,安装命令
C:\Users> pip3 install --upgrade tensorflow-gpu
安装需要一段时间
2,检查安装情况
>>> import tensorflow as tf >>> hello = tf.constant('Hello, TensorFlow!') >>> sess = tf.Session() 2017-08-09 14:52:23.201128: I c:\tf_jenkins\home\workspace\release-win\m\windows -gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:940] Found device 0 with properties: name: GeForce 940M major: 5 minor: 0 memoryClockRate (GHz) 0.98 pciBusID 0000:04:00.0 Total memory: 1.00GiB Free memory: 958.17MiB 2017-08-09 14:52:23.201128: I c:\tf_jenkins\home\workspace\release-win\m\windows -gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:961] DMA: 0 2017-08-09 14:52:23.201128: I c:\tf_jenkins\home\workspace\release-win\m\windows -gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:971] 0: Y 2017-08-09 14:52:23.201128: I c:\tf_jenkins\home\workspace\release-win\m\windows -gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1030] Creating Tenso rFlow device (/gpu:0) -> (device: 0, name: GeForce 940M, pci bus id: 0000:04:00. 0) >>> print(sess.run(hello)) b'Hello, TensorFlow!' >>> hello = tf.constant('Hello, world!') >>> print(sess.run(hello)) b'Hello, world!'
以上信息表明 tensorflow-gpu 已经安装成功,而且能识别到 GPU 进行计算了
如果出现以下错误,表明 CUDA 和 cuDNN 安装不对,请查看之前的文章,找到对应的版本重新安装
ImportError: DLL load failed: ImportError: No module named '_pywrap_tensorflow_internal'
Leave a Reply