Install Tensorflow with GPU support on Windows 10

I am writing this little guide for people who, like myself, have the following characteristics:

  • Have a computer with a decent enough GPU
  • Use this computer to play games
  • Would like to use it also to run experiments on Tensorflow
  • Are too lazy to build a dual boot with linux to proper run it
  • Are also too lazy to install packages and prefer using Anaconda

I remember it was a huge pain to make Tensorflow work with my GPU (980ti) the first time I tried and recently my Windows 10 machine crashed and I had to install it all again (thank you Microsoft!)

Bear in mind that this guide was written in 2017-June and given the speed in which Tensorflow related stuff moves it has an increasing probability of being outdated the farther you are reading it from this date

Steps:

1 – Download and install Anaconda 3.6

https://www.continuum.io/downloads

1.1 Add Anaconda to the Path variable

  • Windows+Break / advanced system settings / system properties / advanced / environment variables
    • under System Variables add   “<your path>\Anaconda3” and “<your path>\Anaconda3\Scripts”

2 – Create a virtual environment:

  • Tensorflow works with Python 3.5 so we will have to create a virtual environment for this.
  • It is important to copy everything when creating this environment otherwise you will have to install it all again
  • In the Windows Command Prompt: “conda create -n tf python=3.5 anaconda”

3 – Install Tensorflow-gpu

  • At the time of this writing the conda instructions on Tensorflow’s website did not work for me, so I had to use pip
  • In the Windows Command Prompt: “pip install –upgrade tensorflow-gpu “

4 – Requirements

5 – Test it

  • Now you should be able to open the Command Prompt and use the following commands
    • activate tensorflow
    • python
    • import tensorflow as tf
    • hello = tf.constant(‘Hello, TensorFlow!’)
    • sess = tf.Session()
    • print(sess.run(hello))
  • If everything was ok, you should see a message telling that it was running on the GPU and the print
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s