Writing CNTK Code using Visual Studio 2017

I took a first stab at writing CNTK based machine learning code using Visual Studio 2017. It worked very nicely and I’m optimistic that CNTK with VS may become my default environment for ML code development.

Visual Studio is Microsoft’s tool for developers to write software. VS has been around for many years. It’s a very complex, very powerful tool.

CNTK v2 is a relatively new code library of sophisticated machine learning functions. CNTK itself is written in C++ but the usual way to use CNTK is through a Python language API.

VS did not directly supported Python until just a few weeks ago. So, in theory at least, all the parts needed to code a CNTK program using VS were in place.

I installed VS2017 on a new machine. Because it was a new installation, I had the option of installing Python support, and so I did. The default Python install for VS2017 has Anaconda v4.4.0 but CNTK requires the older Anaconda v4.1.1 so I found the older version and installed it. Anaconda is a base Python plus many related libraries that are more or less essential, notably NumPy and SciPy.

I installed the legacy Anaconda 4.1.1 then I used the PIP utility to install CNTK v2.2 by pointing to a .whl (“wheel”) file. As I’m writing this blog post, it occurs to me that all this sounds somewhat complicated. It is. In a few years, all of these dependencies will probably just be part of a regular VS installation.

With everything installed, I launched Visual Studio and created a new Python application. I found the Python Environments window in VS, and changed the default from v4.4.0 to my older version of v4.1.1 and then I waited several minutes for the system to update itself — downloading and installing data for the auto-complete feature of VS.

I typed in some CNTK code, and the auto-complete feature worked perfectly:

And then I ran the demo through the debugger, and, somewhat surprisingly, the program ran:

There’s no real big moral to the story here. I was able to get a CNTK environment up and running in VS2017 quite easily because I’ve been doing things like this for many years. I suspect that someone new to ML + VS Python + CNTK would have a very rough time getting everything to work.

This entry was posted in CNTK. Bookmark the permalink.