0%

install and configure tensorflow on windows 10

Series

Tutorial

version

version 1:

  • windows 10 64 bit + GTX 1060(8G) + cuda driver
  • windows 10 64 bit + GTX 1080(12G) + cuda driver
  • CUDA 8.0 + cudnn 6.0.1(win10) + tensorflow-gpu 1.4.0
  • python 3.5.3

version 2:

  • windows 10 64 bit + GeForce Titan Xp(12G) + cuda driver for Titan xp
  • CUDA 9.0 + cudnn 7.1.4(win10) + tensorflow-gpu 1.8.0 ( 1.8.0, 1.9.0 for cuda 9.0)

version 3:

  • windows 10 64 bit + Quadro P4000(8G) + cuda driver for Quadro P4000(实测用Titan Xp的driver也可以)
  • CUDA 9.0 + cudnn 7.1.4(win10) + tensorflow-gpu 1.8.0 ( 1.8.0, 1.9.0 for cuda 9.0)

errors

error retrieving driver version: Unimplemented: kernel reported driver version not implemented on Windows

see tensorflow-gpu==1.4.0

Tips: for tensorflow-gpu==1.4.0
on linux, support python 2.7,3.3,3.4,3.5,3.6.
on windows, only support python 3.5,3.6.

see tensorflow-gpu==1.8.0

Tips: for tensorflow-gpu==1.8.0
on linux, support python 2.7,3.3,3.4,3.5,3.6.
on windows, only support python 3.5,3.6.

from Tensorflow1.6 use CUDA9.0+cuDNN7.

tensorflow download pages

cuda & cudnn

see Part 1: Install and Configure Caffe on windows 10

system env

1
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin

python

install python 3.5.3,add python and pip path to system env.

copy python.exe to python3.exe,
copy pip.exe to pip3.exe

system env

1
2
C:\Users\zunli\AppData\Local\Programs\Python\Python35\
C:\Users\zunli\AppData\Local\Programs\Python\Python35\Scripts

test

1
2
3
4
python3
Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 16:02:32) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ^Z

pip3

1
2
pip3 -V
pip 9.0.1 from c:\users\zunli\appdata\local\programs\python\python35\lib\site-packages (python 3.5)

tensorflow

1
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple Pillow scipy sklearn scikit-image matplotlib

1.4.0

1
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu==1.4.0 keras=2.1.0

1.8.0

1
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu==1.8.0 keras=2.2.0

test tensorflow

1
2
3
4
5
6
import tensorflow as tf
import numpy as np

hello=tf.constant('hhh')
sess=tf.Session()
print (sess.run(hello))

test cuda and gpu

1
2
3
4
5
6
7
8
9
10
11
import tensorflow as tf

a = tf.test.is_built_with_cuda() # 判断CUDA是否可以用

b = tf.test.is_gpu_available(
cuda_only=False,
min_cuda_compute_capability=None
) # 判断GPU是否可以用

print(a)
print(b)

test gpu

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import tensorflow as tf

with tf.device('/cpu:0'):
a = tf.constant([1.0, 2.0, 3.0], shape=[3], name='a')
b = tf.constant([1.0, 2.0, 3.0], shape=[3], name='b')
with tf.device('/gpu:0'):
c = a + b

# 注意:allow_soft_placement=True表明:计算设备可自行选择,如果没有这个参数,会报错。
# 因为不是所有的操作都可以被放在GPU上,如果强行将无法放在GPU上的操作指定到GPU上,将会报错。
sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True, log_device_placement=True))
# sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
sess.run(tf.global_variables_initializer())
print(sess.run(c))

gpu run

pycharm

run code with pycharm

pycharm with python3

jupyter notebook

1
2
3
4
pip install ipykernel
python -m ipykernel install --user --name=tensorflow

Installed kernelspec tensorflow in C:\Users\zunli\AppData\Roaming\jupyter\kernels\tensorflow

error fix

errors:

No matching distribution found for tensorflow

solution: use python 3.5 instead of python 2.7

Reference

History

  • 20180829: created.