Now, I'm happy to learn that TensorFlow now officially supports Windows. The release notes suggests that Windows compatibility was present from TensorFlow v0.12.0 RC0, and it has been tested on Windows 7, Windows 10, and Windows Server 2016. It only supports 64-Bit Python 3.5. Both the standard Python distribution (from Python.org) and Anaconda Python are supported.
This was great news for me, since I was switching between Linux and Windows for my machine learning experiments. So, I gave a try to setup TensorFlow on Windows.
I've been using Anaconda Python for most of my experiments, so I created an Anaconda environment - named 'tensorflow' - with all the basic packages I need.
conda create --name tensorflow numpy scipy scikit-learn pillow h5py mingw libpython
Then I activated the environment I just created,
activate tensorflow
Now for the big step, installing TensorFlow from pip.
I chose the CPU only version for testing. (I will test out the GPU version later)
pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.1-cp35-cp35m-win_amd64.whl
Created the environment, and running the TensorFlow install command |
The installation went ahead. But it seems TensorFlow overwrites some of the packages installed by conda.
Installation overwriting some conda packages |
The install completed, but I got a FileNotFoundError for setuptools-27.2.0-py3.5.egg.
The FileNotFoundError at the end of the installation |
After the install, when I checked the list of installed packages using conda list, it showed that numpy and setuptools packages has been duplicated - one installed by conda and another by pip.
Packages duplicated after the installation |
However, when I tested the TensorFlow installation, using the instructions from the official setup guide, the test commands ran successfully.
python
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print(sess.run(a + b))
Testing the TensorFlow installation |
I still wasn't satisfied with the installation - since it has overwritten the conda packages, and it gave an error at the end of the install. So, I decided to remove the conda environment, and try again.
deactivate
conda remove --name tensorflow --all
conda create --name tensorflow numpy scipy scikit-learn pillow h5py mingw libpython
activate tensorflow
This time, I used the following 2 commands to install only the missing dependencies, and leave the already installed packages intact.
pip install --upgrade --no-deps https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.1-cp35-cp35m-win_amd64.whl
pip install https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.1-cp35-cp35m-win_amd64.whl
Re-installing TensorFlow while keeping the dependencies intact |
Tested the installation again, and it ran successfully again,
Re-testing the installation, successfully |
Finally, I ran the MNIST example in TensorFlow, and it too ran without errors.
python -m tensorflow.models.image.mnist.convolutional
Running the MNIST example on TensorFlow on Windows |
Now, I'm ready to experiment with TensorFlow on Windows.
Summary
In order to properly install TensorFlow on Windows on Anaconda Python, use the following steps.
- Create and activate an Anaconda environment, with the following libraries,
conda create --name tensorflow numpy scipy scikit-learn pillow h5py mingw libpython activate tensorflow
- Install Tensorflow from pip with only the missing dependencies (not upgrading already installed packages),
pip install --upgrade --no-deps https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.1-cp35-cp35m-win_amd64.whl pip install https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.1-cp35-cp35m-win_amd64.whl
- Test the installation,
python >>> import tensorflow as tf >>> hello = tf.constant('Hello, TensorFlow!') >>> sess = tf.Session() >>> print(sess.run(hello)) Hello, TensorFlow! >>> a = tf.constant(10) >>> b = tf.constant(32) >>> print(sess.run(a + b))
- Run an example model, e.g. MNIST
python -m tensorflow.models.image.mnist.convolutional
I'll test out the TensorFlow GPU version on Windows next.
Update 10/Mar/17: I've added a new post on Setting up TensorFlow with CUDA on Windows.
Related Links:
- https://github.com/tensorflow/tensorflow/releases/tag/0.12.0-rc0
- https://www.tensorflow.org/get_started/os_setup#pip_installation_on_windows
- https://www.tensorflow.org/get_started/os_setup#test_the_tensorflow_installation
- https://pip.pypa.io/en/stable/user_guide/#only-if-needed-recursive-upgrade
Build Deeper: Deep Learning Beginners' Guide is the ultimate guide for anyone taking their first step into Deep Learning.
Get your copy now!
perfect, written just right in time as I now tried to install tf on win10. Solves all the installer problems. Thank you!
ReplyDeleteYou are welcome!
DeleteI'm glad this helped :)