Skip to content

Setup Windows Binary Script

Wolfgang Manousek edited this page Mar 16, 2017 · 61 revisions

CNTK binary installation with scripts on Windows

This page will walk you through the process of installing the Microsoft Cognitive Toolkit (CNTK) for Windows based on a binary distribution.

If you are looking for any other kind of support in setting up a CNTK build environment or installing CNTK on your system, you should go here instead.

These instructions apply to release 2.0.beta15.0.

We will install the CNTK binaries, the CNTK prerequisites, samples, tutorials, and by default create a new Python 3.5 environment on your computer. The here described script also supports options to create a Python 2.7 or Python 3.4 environment as well as various other additional options. A detailed overview of the supported install options is here.

The changes are as much localized as possible to not impact any other installed software. We have tested the Microsoft Cognitive Toolkit on Windows 8.1, Windows 10 and Windows Server 2012 R2 (and later).

Once you have download and unpacked the precompiled package, you can run an install script that will perform the following steps:

  • If required the VS2015 Runtime will be installed
  • If required MSMPI will be installed
  • Anaconda3 will be installed into the folder C:\local\Anaconda3-4.1.1-Windows-x86_64
  • A CNTK-PY35 environment will be created or updated in C:\local\Anaconda3-4.1.1-Windows-x86_64\envs
  • The CNTK Python module will be installed or updated in the created CNTK-PY35 environment
  • A batch file will be created to activate the created Python environment and set the required environment variables

In the following we assume you are running the script using the default options. If you changed the options as described here or the install location, please adjust the following instructions accordingly.

Step 1: Download and prepare the Microsoft Cognitive Toolkit

Download the appropriate binary package from CNTK Releases page. The installation described on this page only works with the binary package. The source code package, which is also available from the CNTK Release page, is NOT required.

Unpack the zip file into an empty local folder of your choice. We recommend you name the folder according to the CNTK version, so you don't mix files of a previously downloaded CNTK version with the newly downloaded files. In the following we will assume you unzipped the files into the directory c:\local\CNTK-2-0-beta15-0. If you used another directory, adjust the following instructions accordingly.

Step 2 Run the installation script

Start a standard windows command prompt, and run the installation script:

cd c:\local\CNTK-2-0-beta15-0
cd cntk\Scripts\install\windows
install.bat

The script will inspect your system and determine the pre-requisites which are missing. You will be notified about the proposed installation steps and locations. This can be adjusted by optional parameters to the install script, see here.

The script will download needed components from the web, a connection to the Internet is required. It will execute these components, and according to the setting of UAC (User Account Control) you will be asked to acknowledge the execution and installation of these components.

Depending on the speed of your system, the Internet connection, and the required components to install, the whole process can take up to 20 minutes. Especially the Anaconda3 install is very time consuming, please be patient.

By the end of the successful setup the script will inform you about the location of the CNTK Python environment batch file and of the location of CNTK Python examples.

Step 3 Update your GPU Driver

If you downloaded/installed the GPU or GPU-1bit-SGD version of CNTK and you are using a NVidia graphics card, ensure that you have the latest NVIDIA driver installed.

Step 4 Verify the setup from Python

To verify the correct installation of CNTK from Python:

You need to activate the CNTK environment by opening a standard Windows command prompt and running the batch file created by the installation script (see Step 2). This script will add Python and the CNTK installation to your current PATH environment only for the current Windows command prompt.

Note: you will need to do this every time you plan to use the CNTK Python environment

cd c:\local\CNTK-2-0-beta15-0
cd scripts
cntkpy35.bat

You can now follow the standard describtion to test your installation from Python and run the tutorials or Jupyter notebooks.

  • If you want to use Python Tools, CNTK, and Visual Studio Code, see this blog.
  • If you want to use Python Tools, CNTK, and Visual Studio, see here

Step 5 Verify the setup for BrainScript

Perform the following command in the CNTK environment command prompt (see previous step):

cd c:\local\CNTK-2-0-beta15-0
cd Tutorials\HelloWorld-LogisticRegression
cntk configFile=lr_bs.cntk makeMode=false command=Train

The last lines of the CNTK output on the console should look similar to this:

Finished Epoch[42 of 50]: [Training] lr = 0.04287672 * 1000; err = 0.01152817 * 1000; totalSamplesSeen = 42000; learningRatePerSample = 0.039999999; epochTime=0.050296s
Finished Epoch[43 of 50]: [Training] lr = 0.04388479 * 1000; err = 0.01206375 * 1000; totalSamplesSeen = 43000; learningRatePerSample = 0.039999999; epochTime=0.052143s
Finished Epoch[44 of 50]: [Training] lr = 0.04223433 * 1000; err = 0.01105073 * 1000; totalSamplesSeen = 44000; learningRatePerSample = 0.039999999; epochTime=0.057235s
Finished Epoch[45 of 50]: [Training] lr = 0.04208072 * 1000; err = 0.01140516 * 1000; totalSamplesSeen = 45000; learningRatePerSample = 0.039999999; epochTime=0.051414s
Finished Epoch[46 of 50]: [Training] lr = 0.04261674 * 1000; err = 0.01158323 * 1000; totalSamplesSeen = 46000; learningRatePerSample = 0.039999999; epochTime=0.051115s
Finished Epoch[47 of 50]: [Training] lr = 0.04326523 * 1000; err = 0.01164283 * 1000; totalSamplesSeen = 47000; learningRatePerSample = 0.039999999; epochTime=0.051611s
Finished Epoch[48 of 50]: [Training] lr = 0.04225255 * 1000; err = 0.01148774 * 1000; totalSamplesSeen = 48000; learningRatePerSample = 0.039999999; epochTime=0.0509s
Finished Epoch[49 of 50]: [Training] lr = 0.04173276 * 1000; err = 0.01124948 * 1000; totalSamplesSeen = 49000; learningRatePerSample = 0.039999999; epochTime=0.049659s
Finished Epoch[50 of 50]: [Training] lr = 0.04399402 * 1000; err = 0.01202178 * 1000; totalSamplesSeen = 50000; learningRatePerSample = 0.039999999; epochTime=0.052725s

COMPLETED.

If you have an NVidia GPU and installed a GPU build, you can also try this command:

cntk configFile=lr_bs.cntk makeMode=false command=Train deviceId=auto

To validate that the GPU was being used, look for the following line in your output:

Model has 9 nodes. Using GPU 0.

Next:

Clone this wiki locally