How to install TensorFlow on Windows?

I am starting to work with the TensorFlow library for deep learning, https://www.tensorflow.org/ .

I found an explicit guide to working on it on Linux and Mac, but I did not find how to work with it on Windows. I try through the network, but not enough information.

I am using Visual Studio 2015 for my projects and I am trying to compile the library with Visual Studio Compiler VC14.

How to install it and use on Windows?

Can I use Bazel for Windows for production?

+43
c ++ windows visual-studio machine-learning tensorflow
Jan 14 '16 at 9:06
source share
11 answers

How to install TensorFlow and use it under Windows?

Updated 8/4/16

Windows 10 now has an Ubuntu Bash environment, AKA Bash on Ubuntu on Windows , available as a standard option (unlike Developer Preview Updates ). (StackOverflow wsl tag ) This option appeared with the Windows 10 Update (Version 1607) released on 8/2/2016. This allows apt-get to be used to install software packages such as Python and TensorFlow .

Note: Bash on Ubuntu on Windows does not have access to the GPU, so all GPU options for installing TensorFlow will not work.

The related installation instructions for Bash on Ubuntu on Windows are mostly correct, but only these steps are needed:
Background
Enable Windows Subsystem for Linux (GUI) Feature
Reboot when prompted
Launch Bash on Windows

The steps are no longer needed:
Enable Developer Mode
Enable Windows Subsystem Feature for Linux (command line)

Then install TensorFlow using apt-get

sudo apt-get install python3-pip python3-dev sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp34-cp34m-linux_x86_64.whl 

and now check out TensorFlow

 $ python3 ... >>> 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)) 42 >>> exit() 

and run a real neural network

 python3 -m tensorflow.models.image.mnist.convolutional 

Previous answer

After reading the preview of the Bash developer on Windows.

See Playing with TensorFlow on Windows by Scott Hanselman, which uses Bash on Windows 10

Original answer

Problem with Bazel

TensorFlow was not created with build automation tools such as make , but with the Google Bazel tool built in. Bazel only works on Unix- based systems such as Linux and OS X.

Since the current published / well-known tool for creating TensorFlow uses Bazel and Bazel does not work on Windows, you cannot install or run TensorFlow natively on Windows.

From Bazel Frequently Asked Questions

What about windows?

Due to its UNIX legacy, porting Bazel to Windows is significant Work. For example, Bazel makes extensive use of symbolic links, which change support levels in versions of Windows.

We are currently actively working to improve Windows support, but it still cannot be used.

Status

See: TensorFlow Error # 17
See: Problem with Bazel # 276

Decision

Decisions are listed in order of complexity and work required; from about an hour to may not even work.

Docker installation

Docker is a system for creating standalone versions of the Linux operating system running on your computer. When you install and run TensorFlow through Docker, it completely isolates the installation from existing packages on your computer.

Also see TensorFlow - which Docker image to use?

  1. OS X
    ~ 1 hour

If you have a current Mac running OS X, then see: Installation for Mac OS X

  1. Linux

Recommended Linux system is trending Ubuntu 14.04 LTS ( Download Page ).

but. Virtual Machine - Hardware Virtualization - Full Virtualization
~ 3 hours

Download and install a virtual machine, such as commercial VMware or the free Virtual Box , after which you can install Linux and then install TensorFlow.

When you move on to installing TensorFlow, you'll use Pip - The Python Package Management System. Visual Studio users should think about NuGet. Packages are known as wheels .

See: Protocol setup

If you need to build from source, see below: Install from sources
~ 4 hours

Note. If you plan to use a virtual machine and have never done it before, consider using the Docker option, since Docker is a virtual machine, OS, and TensorFlow, all packaged together.

b. Dual boot
~ 3 hours

If you want to run TensorFlow on the same computer on which Windows is installed and use the GPU version, you will most likely have to use this parameter as a virtual machine, type 2 hypervisor that will not allow you to access the GPU.

  1. Remote machine
    ~ 4 hours

If you have remote access to another computer on which you can install Linux and TensorFlow software and allow remote connections, you can use your Windows computer to present the remote computer as an application running on Windows.

  1. Cloud service
    I have no experience with this. If you know, edit the answer.

Cloud such as AWS are used.

From TensorFlow Opportunity

Want to run a model as a service in the cloud? Containerize with Docker and TensorFlow only work.

From docker

Running Docker on AWS provides a highly reliable, low-cost way to quickly create, send, and run distributed applications on a scale. Docker deployment using AMI from the AWS market.

  1. Wait for Bazel to work on Windows.

Currently, it seems that Bazel is the only retention, however, this year a list of Bazel's Windows-based roadmap should appear.

There are two functions for Windows:

 2016‑02 Bazel can bootstrap itself on Windows without requiring admin privileges. 2016‑12 Full Windows support for Android: Android feature set is identical for Windows and Linux/OS X. 
  1. Build TensorFlow manually.
    A few days or more, depending on your skill level. I have given up on this; too many subprojects to build and files to search.

Remember that Bazel is only used to create TensorFlow. If you get Bazel commands, and the correct source code and libraries, you should be able to create TensorFlow on Windows. See: How to get the commands executed by Bazel .

While I have not researched this yet, you can see the continuous integration for the necessary files and information on how to build them for testing. ( Readme ) ( site )

  1. Build Bazel on Windows
    A few days or more, depending on your skill level. I also refused this; could not find the required source files needed for windows.

There is a public experimental version of the Bazel source code that loads on Windows . You can use this to make Bazel work on Windows, etc.

These solutions also require the use of Cygwin or MinGW , which adds another level of complexity.

  1. Use an alternate build system such as Make
    If you get this to work, I would like to look at GitHub.

TensorFlow does not currently exist. This is a feature request.

See: TensorFlow Task 380

  1. Cross construction
    If you get this to work, I would like to look at GitHub.

You create TensorFlow on Linux using Bazel, but modify the build process to bring out the wheel that can be installed on Windows. This will require detailed knowledge of Bazel in order to reconfigure and find the source code and libraries that work with Windows. An option that I would suggest only as a last resort. Perhaps this is not even possible.

  1. Launch the new Windows subsystem for Linux.

See: Windows Subsystem Overview for Linux

You will know as much as I do by reading the article that is referenced.

Can I use Bazel for Windows for production?

Since this is experimental software that I would not use on a production machine.

Remember that you only need Bazel to create TensorFlow. Therefore, use the experimental code on a non-production machine to create a wheel , then install the wheel on the production machine. See: Protocol setup

TL; DR;

I currently have several versions for training. Most use a VMWare 7.1 workstation to host Ubuntu 14.04 LTS or Ubuntu 15 or Debian. I also have one dual boot Ubuntu 14.04 LTS on my Windows machine to access the GPU, since the VMware machine does not have a corresponding GPU. I would recommend that you provide these computers with at least 8 GB of memory, either in RAM or in RAM, and in the swap space, since I ran out of memory several times.

+62
Jan 14 '16 at 11:44
source share

I can confirm that it works in the Windows subsystem for Linux! And it is also very simple.

On Ubuntu Bash on Windows 10, first update the package index:

 apt-get update 

Then install pip for Python 2:

 sudo apt-get install python-pip python-dev 

Install tensor flow:

 sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl 

Now the package is installed, you can run the CNN sample in the MNIST set:

 cd /usr/local/lib/python2.7/dist-packages/tensorflow/models/image/mnist python convolutional.py 

I just tested the processor package.

I wrote about this: http://blog.mosthege.net/2016/05/11/running-tensorflow-with-native-linux-binaries-in-the-windows-subsystem-for-linux/

amuses

~ michael

+16
May 11 '16 at 20:36
source share

Sorry for the excavation, but this question is quite popular, and now it has a different answer.

Google officially announced the addition of TensorFlow support for Windows (7, 10 and Server 2016): developers.googleblog.com

The Python module can be installed using pip with a single command:

 C:\> pip install tensorflow 

And if you need GPU support:

  C:\> pip install tensorflow-gpu 

TensorFlow Guide - How to install pip on windows

Other useful information is included in the release notes: https://github.com/tensorflow/tensorflow/releases

UPD: Like @ m02ph3u5 mentioned in TF comments for Windows only supports Python 3.5.x Installing TensorFlow on Windows with native pip

+6
Nov 30 '16 at 7:13
source share

Install TensorFlow

TensorFlow currently only supports the 64-bit version of Python 3.5. Both CPU and GPU are supported. Here are a few installation instructions assuming you don't have Python 3.5 64-bit:




TensorFlow Testing

Now you can run something like the following to check if TensorFlow is working fine:

 import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello)) a = tf.constant(10) b = tf.constant(32) print(sess.run(a + b)) 

TensorFlow comes with several models that are located in C:\Python35\Lib\site-packages\tensorflow\models\ (assuming you installed python in C:\Python35 ). For example, you can start the console:

 python -m tensorflow.models.image.mnist.convolutional 

or

 python C:\Python35\Lib\site-packages\tensorflow\models\image\mnist\convolutional.py 



Windows TensorFlow Limitations

Initial support for building TensorFlow in Microsoft Windows was added in 2016-10-05 at commit 2098b9abcf20d2c9694055bbfd6997bc00b73578 :

This PR contains the initial support for creating TensorFlow (CPU only) on Windows using CMake. It includes documentation for building with CMake on Windows, platform-specific code for implementing core functions on Windows, and CMake rules for building a C ++ example tutorial and PIP package (Python 3.5 only). CMake rules support the creation of TensorFlow using Visual Studio 2015.

Windows support is a work in progress, and we welcome your feedback and contributions.

For more information on supported features and instructions on how to create TensorFlow on Windows, see tensorflow/contrib/cmake/README.md .

Microsoft Windows support was introduced in TensorFlow in version 0.12 RC0 ( release notes ):

TensorFlow now builds and runs on Microsoft Windows (tested on Windows 10, Windows 7, and Windows Server 2016). Supported languages ​​include Python (via pip) and C ++. CUDA 8.0 and cuDNN 5.1 are supported for GPU acceleration. Known limitations include: It is currently not possible to load the op user library. GCS and HDFS file systems are not currently supported. The following Opsa not currently: DepthwiseConv2dNative, DepthwiseConv2dNativeBackpropFilter, DepthwiseConv2dNativeBackpropInput, dequantization, digamma, ERF, ERFC, Igamma, Igammac, Lgamma, polygamma, QuantizeAndDequantize, QuantizedAvgPool, QuantizedBatchNomWithGlobalNormalization, QuantizedBiasAdd, QuantizedConcat, QuantizedConv2D, QuantizedMatmul, QuantizedMaxPool, QuantizeDownAndShrinkRange, QuantizedRelu, QuantizedRelu6 , QuantizedReshape, QuantizeV2, RequantizationRange, and Requantize.

+5
Oct 06 '16 at 18:04
source share

Tensorflow is now officially supported on Windows, you can install it using the pip Python 3.5 command without compilation.

CPU version

 pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0-cp35-cp35m-win_amd64.whl 

cp35 stands for python 3.5 wheel, 0.12.0 version, you can edit them according to your preferences or install the latest available CPU version that you can use

 pip install --upgrade tensorflow 

GPU version

 pip install --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0-cp35-cp35m-win_amd64.whl 

cp35 stands for python 3.5 wheel, 0.12.0 version, you can edit them according to your preferences or install the latest GPU version that you can use

 pip install --upgrade tensorflow-gpu 

Additional Information

+4
Nov 30 '16 at 14:14
source share

The following might work for you: install Virtual Box, create a Linux VM, and install Linux on it. I would recommend Ubuntu because Google often uses it internally. Then install TensorFlow on the Linux VM.

+3
Jan 14 '16 at 10:37
source share

You cannot now. The problem is that schedorflow uses bazel build another Google internal tool that was opened as an open source project , and it only supports mac and unix, until the database is moved to windows or another system is added assemblies, in the tensor flow there is a small opportunity to start the tensor flow initially on the windows.

Having said that, you can install the virtual box and then install the docker machine and run the linux container with the tensor flow inside it.

+1
Jan 14 '16 at 10:02
source share

I managed to install TensorFlow on Win8.1 without Docker, using tips from https://discussions.udacity.com/t/windows-tensorflow-and-visual-studio-2015/45636

I tried many things before this, and I will not try to install it twice, but here's what I did: - install VS2015 (make sure Visual C ++ is also installed) - install Python Tools for VS2015 - install Python2.7 using Anaconda2 - install pip and conda for Python - install numpy using pip inside VS2015 - install tensor flow with pip inside VS2015

I failed to do this using Python3.5

I also managed to install on Win8.1 through Cloud9. There is a video tutorial on Youtube.

https://www.youtube.com/watch?v=kMtrOIPLpR0

EDIT: actually for the above (not Cloud9, which is ok) I have problems: TensorFlow LOOKS LIKE it is installed (I can see it in the list of modules installed in VS2015 when I clicked in the solution explorer on a 64-bit version of Python 2.7) but if I type a script or in Python Interactive import tensorflow as TF , then I get an error

 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\__init__.py", line 23, in <module> from tensorflow.python import * File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\__init__.py", line 50, in <module> from tensorflow.python.framework.framework_lib import * File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\framework\framework_lib.py", line 62, in <module> from tensorflow.python.framework.ops import Graph File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\framework\ops.py", line 40, in <module> from tensorflow.python.framework import versions File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\framework\versions.py", line 24, in <module> from tensorflow.python import pywrap_tensorflow File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module> _pywrap_tensorflow = swig_import_helper() File "C:\Users\Fagui\Anaconda2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper import _pywrap_tensorflow 

enter image description here

+1
Feb 07 '16 at 15:08
source share

As this answer wrote, I was not able to correctly configure fiforflow using python version 3.5.2. Returning to python 3.5.0 did the trick.

Then I managed to install using

C:> pip install tensorflow

+1
Dec 26 '16 at 21:43
source share

If you have already installed anaconda in your windows, there is an easier way, as I found out:

 conda create --name snakes python=3 

Then

 activate snakes 

Then

 pip install tensorflow 

This is similar to virtualenv, and I found it useful.

+1
Jan 19 '17 at 5:08 on
source share

Follow this link to install Tensorflow on Windows, and you can also use it in Visual Studio

-one
Dec 01 '16 at 18:35
source share



All Articles