Scott Hanselman

Playing with TensorFlow on Windows

May 15, '16 Comments [33] 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
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Sunday, 15 May 2016 19:15:20 UTC
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)
Andrew Murphy
Sunday, 15 May 2016 21:18:43 UTC
Yes I believe those were fixed this build. Check the Github or release notes blog.
Scott Hanselman
Sunday, 15 May 2016 21:25:26 UTC
Build 14422?
That's not a public build is it?
Christer
Sunday, 15 May 2016 22:49:11 UTC
Christer - sorry, typo. It's 14342, public insiders build.
Scott Hanselman
Sunday, 15 May 2016 23:00:49 UTC
Very cool! Does Keras also run out of the box?
Monday, 16 May 2016 02:32:58 UTC
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.
Shaun Bedingfield
Monday, 16 May 2016 06:58:26 UTC
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
Monday, 16 May 2016 07:17:06 UTC
The lack of GPU supprt is indeed significant in the area of machine learning. Would be great if that works at some point.
Frank Quednau
Monday, 16 May 2016 10:48:30 UTC
Monday, 16 May 2016 12:05:33 UTC
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.
Mark Adamson
Monday, 16 May 2016 13:09:33 UTC
@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.
Monday, 16 May 2016 13:21:56 UTC
@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.
Shaun Bedingfield
Monday, 16 May 2016 14:14:37 UTC
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.
Ruze Richards
Tuesday, 17 May 2016 04:38:42 UTC
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?
Scott Hanselman
Tuesday, 17 May 2016 04:57:21 UTC
Please no "TensorFlow tooling for Visual Studio" blog post announcement. Visual Studio has enough features/tooling used by < 3% of users in it already.


Greg
Tuesday, 17 May 2016 18:28:34 UTC
@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.
Ruze Richards
Wednesday, 18 May 2016 06:25:00 UTC
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
Redmor
Wednesday, 18 May 2016 09:21:54 UTC
very cool !
Thursday, 19 May 2016 08:48:39 UTC
Is Microsoft the next IBM?!
MiHO
Saturday, 21 May 2016 03:16:58 UTC
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.
Shaun Bedingfield
Tuesday, 24 May 2016 02:15:33 UTC
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%....
Tuesday, 24 May 2016 21:28:57 UTC
very cool ! thanks for information
Tuesday, 24 May 2016 21:29:33 UTC
very good, thanks for information
Tuesday, 31 May 2016 13:22:20 UTC
http://d1537576.u172.host.ie
http://www.brettnerbuch.at
http://www.www.rubblemaster.ca
http://filtretoptancisi.com
http://www.yazicikardesler.com
http://klaspak.com
http://spm-sued.at
http://www.rent-or-buy.at
http://physiotherapie-weber.at
http://d2038281.u172.host.ie
http://d1852488.u172.host.ie
http://www.asmalibag.com
http://foodland.ie
http://www.albayramsigorta.com
http://d1650807.ali172.enclave-technologies.com
Monday, 06 June 2016 19:51:02 UTC
Thanks for the link collection. There were a couple I hadn't heard about there.

Greg
Greg Sohl
Sunday, 12 June 2016 05:15:12 UTC
Nice and so informative information is present in this website.Thank you so much continue postings.
Sunday, 12 June 2016 10:03:52 UTC
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.
Niclas Lindgren
Monday, 20 June 2016 23:22:52 UTC
I'll just place this here:
http://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/
Matt Johnson
Wednesday, 22 June 2016 07:05:17 UTC
tensor flow this new to here about this thanks for the information...
Wednesday, 22 June 2016 07:06:33 UTC
what an information no one know about these features thanks
Wednesday, 22 June 2016 13:01:43 UTC
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
Aaron Hughes
Saturday, 02 July 2016 16:37:31 UTC
>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
Monday, 25 July 2016 02:19:16 UTC
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.