TensorFlow(tm) on Windows

As you might already know, TensorFlow(tm) could not run natively on Windows. At the time you had to run it on a VM or a Docker container. Earlier this month Google released a native version for Windows. This morning I woke up around 04:00 AM and decided to install it on my computer to have it available over the weekend. The installation is quite simple and it works as I will show.

Initially I ran into problems due to different versions of Anaconda and Python on my machine. The instructions from Google call for Python 3.5 (or higher). I had installed different versions (i.e., Python 2.7) plus Python Tools 2.2 for Visual Studio 2013. I decided to remove programs in order, leaving Python for VS towards the end. I really wanted to avoid removing such package.

I tested python (python –version) and 2.7 showed up. Removed Anaconda and restarted my machine. Same result. I decided to remove all versions of Python. I restarted my machine. Python was gone. I then went back to the installation instructions by Google.

One needs to install Python 3.5 or higher. The following information was used to accomplish such task:

Parameter Value
URL https://www.python.org/downloads/release/python-352/
File downloaded C:\temp\python-3.5.2-amd64.exe
Installation Folder C:\Program Files\Python35

I performed a custom installation for Python. It was installed in the C:\Program Files\Python35 folder.

To verify the installation, from a command prompt enter the following command:

C:\> python -V

Python 3.5.2

Success!!! Python 2.7 was gone.

I then created a simple Python project using VS 2013. The code for it follows:

import sys

print(‘hello world’)

version = sys.version_info

print(version)

The output for the program:

hello world

sys.version_info(major=3, minor=5, micro=2, releaselevel=’final’, serial=0)

Press any key to continue . . .

All was good so far.

To install TensorFlow from a command prompt enter:

C:\> pip install tensorflow

Collecting tensorflow

Using cached tensorflow-0.12.0rc1-cp35-cp35m-win_amd64.whl

Collecting six>=1.10.0 (from tensorflow)

Using cached six-1.10.0-py2.py3-none-any.whl

Collecting wheel>=0.26 (from tensorflow)

Using cached wheel-0.29.0-py2.py3-none-any.whl

Collecting protobuf==3.1.0 (from tensorflow)

Using cached protobuf-3.1.0-py2.py3-none-any.whl

Collecting numpy>=1.11.0 (from tensorflow)

Using cached numpy-1.11.2-cp35-none-win_amd64.whl

Requirement already satisfied (use –upgrade to upgrade): setuptools in c:\program files\python35\lib\site-packages (from protobuf==3.1.0->tensorflow)

Installing collected packages: six, wheel, protobuf, numpy, tensorflow

Successfully installed numpy-1.11.2 protobuf-3.1.0 six-1.10.0 tensorflow-0.12.0rc1 wheel-0.29.0

You are using pip version 8.1.1, however version 9.0.1 is available.

You should consider upgrading via the ‘python -m pip install –upgrade pip’ command.

To update pip from a command console:

C:\> python -m pip install –upgrade pip

Collecting pip

Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)

100% |################################| 1.3MB 365kB/s

Installing collected packages: pip

Found existing installation: pip 8.1.1

Uninstalling pip-8.1.1:

Successfully uninstalled pip-8.1.1

Successfully installed pip-9.0.1

To verify the operation of TensorFlow from a command prompt:

C:\> python

Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32

Type “help”, “copyright”, “credits” or “license” for more information.

>>> import tensorflow as tf

>>> hello = tf.constant(‘Hello, TensorFlow!!!’)

>>> sess = tf.Session()

>>> print(sess.run(hello))

b’Hello, TensorFlow!!!’

>>> a = tf.constant(10)

>>> b = tf.constant(32)

>>> print(sess.run(a + b))

42

>>> quit()

C:\>

Seems all is well so far. Over the weekend will experiment with this installation and then will see if I can move my NVIDIA Tesla card from a PC running Linux to this one running Windows 10.

If you have comments or questions regarding this blog post or any other entry, please do not hesitate and send me a message via email. I will keep your name in confidence unless you state different.

John

John.canessa@gmail.com

Follow me on Twitter: @john_canessa

Leave a Reply

Your email address will not be published. Required fields are marked *