Scott Hanselman

Playing with TensorFlow on Windows

May 15, 2016 Comment on this post [25] Posted in Open Source
Sponsored By

TensorFlow is a machine learning library from Google. There are no Windows builds but I wanted to run it on Windows. There are some other blog posts that show people trying to get TensorFlow running on Windows with VMs or Docker (using a VM) but they are a little complex. This seems like a great chance to see of I can just run Bash on Windows 10, build TensorFlow and run it.

TensorFlow on Ubuntu on Windows 10

I'm running Windows 10 Insiders Build 14422 as of the time of this writing. I launched Bash on Windows and followed these pip (Python) instructions, just as if I was running Linux. Note that the GPU support won't work so I followed the CPU only instructions from my Surface Pro 3.

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

It built, then I tested it like this:

$ 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))
42
>>>

Cool, but this is Hello World. Let's try the more complex example against the MINST Handwriting Models. The simple demo model for classifying handwritten digits from the MNIST dataset is in the sub-directorymodels/image/mnist/convolutional.py. You'll need to check when your mnist folder is.

$ cd tensorflow/models/image/mnist
$ python convolutional.py
Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes.
Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes.
Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes.
Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes.
Extracting data/train-images-idx3-ubyte.gz
Extracting data/train-labels-idx1-ubyte.gz
Extracting data/t10k-images-idx3-ubyte.gz
Extracting data/t10k-labels-idx1-ubyte.gz
Initialized!
Step 0 (epoch 0.00), 9.3 ms
Minibatch loss: 12.054, learning rate: 0.010000
Minibatch error: 90.6%
Validation error: 84.6%
Step 100 (epoch 0.12), 826.7 ms
Minibatch loss: 3.289, learning rate: 0.010000
Minibatch error: 6.2%
Validation error: 7.0%
...

This set appears to be working great and is currently on Step 1500

There's bugs in the Bash on Windows 10, of course. It's in Beta. But it's not a toy, and it's gonna be a great addition to my developer toolbox. I like that I was able to follow the Linux instructions exactly and they just worked. I'm looking forward to seeing how hard I can push Ubuntu and Bash on Windows 10.


Sponsor: Big thanks to SQL Prompt for sponsoring the feed this week! Have you got SQL fingers? TrySQL Prompt and you’ll be able to write, refactor, and reformat SQL effortlessly in SSMS and Visual Studio.Find out more.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
May 15, 2016 23:15
Do you know if the issues with symlinks and the linux subsystem are fixed yet?

Without that support it's basically useless for my company as we can't install node version manager (NVM)
May 16, 2016 1:18
Yes I believe those were fixed this build. Check the Github or release notes blog.
May 16, 2016 1:25
Build 14422?
That's not a public build is it?
May 16, 2016 2:49
Christer - sorry, typo. It's 14342, public insiders build.
May 16, 2016 3:00
Very cool! Does Keras also run out of the box?
May 16, 2016 6:32
Tensorflow is quite interesting. I was hoping it might help make it easier to bring machine learning to the masses but from reading the examples it becomes apparent that it's target audience is developers who already have a good foundation in theory and want to use it as a toolbox for building a wide array of pattern recognition solutions. It doesn't mean it is not useful just that it is targeted a little bit more toward the intermediate to advanced community and creating good pattern recognition using it requires a strong understanding of the data.

One day perhaps we can have a framework that suggests strategies, guides, and tunes itself to a degree but that is not yet today. I do not think we will ever get to a point where understanding data is trivial but simple problems should be simple and some of these problems are tomorrow's simple problems.

Perhaps it is a statement on where we are on machine learning. We are to the point where the technology is starting to seep more into mid-size development shops that might have access to a small handful of experts but despite constant statements of an AI first future, machine learning is not yet ubiquitous.

Still, I think it should pose a challenge to many developers out there. Machine learning is becoming more accessible and what once was a graduate level or theoretical topic is having real impact in the industry (you only have to watch build or google's recent presentations to understand this). It will not be long before good machine learning classes become standard in undergraduate programs and in ten years, understanding machine learning may be part of the average developer's job.

The constant challenge to learn new things is part of what makes a great developer. I hope more people challenge themselves to step up and embrace the brand new worlds that are being created all the time. It is really nice to see this on this blog.
May 16, 2016 10:58
I'm really excited about this. I'm currently holing out for the public release.

No GPU support is a real shame though, since TensorFlow obviously thrives on GPUs.
Do you know whether that'll be part for the final Windows 10 Bash integration?
Sam
May 16, 2016 11:17
The lack of GPU supprt is indeed significant in the area of machine learning. Would be great if that works at some point.
May 16, 2016 14:48
May 16, 2016 16:05
The bash stuff does look cool, but I'm actually more excited that you are maybe getting into machine learning. I challenged myself to learn and use R this year at work in a new machine learning model which is working out very well.

Next year python.
May 16, 2016 17:09
@Shaun - I have found that Azure ML Studio is the best bet for people who want to get started with ML without an advanced Data Science degree. You can also leverage some of the great ML libraries like Azure Cognitive Services and IBM Watson if you just need some quick-and-dirty capabilities. Obviously, you can do quite a bit more with ML Studio or TensorFlow than you can with the ML libraries, but the learning curve goes up quite a bit once you do that.
May 16, 2016 17:21
@joe. Thanks for the shout out. Personally, at this point I am planning on bulking up a bit in the area. I have a good learning curve so it shouldn't be a huge challenge.

I am glad there are other alternatives available that are more approachable. Still, I think the hallmark of a great library is that simple things are simple and complex things are possible. I would like to see libraries that allow people to grow with them and make progressively better solutions by investing more time and knowledge.

In the future, this is not going to be advanced data science; it is just going to be normal work.
May 16, 2016 18:14
I'm curious as to how to get the initial pip and dev packages install to work.
$ sudo apt-get install python-pip python-dev

I always get:
E: Sub-process /usr/bin/dpkg returned an error code (1)

and it seems related to mounting proc:
the keytool command requires a mounted proc fs (/proc).

Are you saying you used it out of the box and it just works? I'm using a fresh install of 14342.
May 17, 2016 8:38
Ruze - Try starting afresh. Save off whatever .bashrc's or whatever you need and from a powershell

lxrun /uninstall /full

Then reboot, and run bash again and start with a fresh isntall on 14342 and try that?
May 17, 2016 22:28
@Scott I tried that and it's still a no go. A little more digging reveals the issue is installing Java (neither Oracle nor the OpenJDK seem to work), and that's a prerequisite for the python packages. It's ok, I can wait for the next pre-release - maybe you can point them to this issue as a worthy one to focus on.
May 18, 2016 10:25
If you work with Nvidia on a CUDA wrapper (similar to the existing wine wrapper for their GPUs) then I'm sold. No more Linux dual boot nor Mac OS...
I hope it'll come, someday
May 21, 2016 7:16
I think Google's strategy with TensorFlow is becoming a little more interesting with their announcement of a TPU.

It will of course place them in direct competition with Nvidia but if it is good enough, it could make some applications a bit more practical.
May 24, 2016 6:15
Learning:


So I got through the steps to run the program and the validation error is 1.4% at step 1700 currently. But Im a Web developer and have a severe lack of fundamental knowledge, despite continual efforts to mitigate this. 2100, and 1.2%... How can I make this specific example give me the context for starting to work inside this amazing field. Im a student in Boulder, CO hoping to expand my knowledge. (Im also running on a mac but am curious for more of a breakdown on the code and theory). This Is obviously a pretty vague/possibly demanding question, but if anyone out there would like to share some insights Id be very eager to hear them. Step 3000 minibatch loss: 2.937, learning rate: .008574, minibatch error 3.1%, validation error 1.1%....
June 06, 2016 23:51
Thanks for the link collection. There were a couple I hadn't heard about there.

Greg
June 12, 2016 9:15
Nice and so informative information is present in this website.Thank you so much continue postings.
June 12, 2016 14:03
I think Ubuntu On Windows is a great thing to be able to use some dev tools and to some extent a developer flow that you might be used to or need in for instance embedded scenarios.

I often, if not always, approach development from a point I call "Deployment first", which essentially means I want to figure out how to deploy what I build to the end users before I actually build something.

This is where Ununtu On Windows starts to become confusing for me, as it means I will plan to release on Ubuntu, which I perhaps don't mind, but feels liks a confusing Microsoft scenario.

So I am curious to see where the end game is for Bash On Windows. The MinGW approach is quite appealing, but it means adapting the code for Linux and abstract the OS layer in the code properly. The Cygwin approach is also very appealing for gettings tools on windows, but it requires an active shim to work and this shim has to be machine unique/global. To have Windows map all the syscalls is a very interesting approach, and one that, so far, only Microsoft can properly do, so there is hope we will get the best of these 3 worlds in the future.

At the moment my biggest blocker for using Bash On Windows is that there needs to be a better interaction between the environments, that you can't edit files in normal "Windows" editors and have then reliably update in the Ubuntu world is at the moment my biggest blocker for even using it in a dev flow.

And a compelling deployment story would also be interesting, unless of course the story is mostly, you don't need to run ubuntu to play with the stuff you can stay in Windows.

Or perhaps this is a precursor to Android on Windows.
June 21, 2016 3:22
I'll just place this here:
http://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/
June 22, 2016 17:01
I'm confused on exactly how to install TensorFlow on windows.

I have TensorFlow r0.9 which I downloaded from this link.

I installed Python 3.4.4 and Docker for windows.

But I'm not able to install TensorFlow. Can you tell me how should I proceed with installation.what are the steps for it. I have Windows 7 (Professional) 64-bit

Thanks
July 02, 2016 20:37
>https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl

>eapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp2

>/linux/cpu/tensorflow

>/cpu/

What's the point?
a1
July 25, 2016 6:19
Wow this is so cool, thanks! I'll be posting a tutorial blog post on my site if I can make this (http://thenaivebayesian.com).

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.