Skip to content

Setup Windows Binary Manual

Mark Hillebrand edited this page Nov 21, 2016 · 35 revisions

Windows manual installation from binary distribution

This page will walk you through the process of manual installing the Microsoft Cognitive Toolkit (CNTK) based on a binary distribution we have prepared and you can download from our website. This is intended for those users who want to have a customized installation. We have tested the Microsoft Cognitive Toolkit on Windows 8.1, Windows 10 and Windows Server 2012 R2.

Note: This instructions apply to release 2.0.beta4.0.

Note: You can find an overview about all the available installation options for CNTK on [this page] (./Setup-CNTK-on-your-machine).

If you previously installed an earlier version of the CNTK Python package, you can jump to step 3 to update existing CNTK package installation from your Python 3.4 environment

Step 1: Install pre-requisites

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.

After you followed the step above, you can now unpack the zip file into a local folder of your choice, although in the following text we will assume you unpacked the package into c:\local. If you installed the zip into a different directory, please adjust the commands given below accordingly.

CNTK on Windows requires the following prerequisites to be installed on your system. Please install them from the links below:

  • The Visual C++ Redistributable Package for Visual Studio 2013 can be installed from c:\local\cntk\prerequisites\VS2013\vcredist_x64.exe

  • The Visual C++ Redistributable Package for Visual Studio 2012 can be installed from c:\local\cntk\prerequisites\VS2012\vcredist_x64.exe

  • Microsoft MPI Version 7 (7.0.12437.6) can be installed from c:\local\cntk\prerequisites\MsMPiSetup.exe. At this point we suggest this version of MSMPI (7.0.12437.6), as this is the version which is currently tested by us in connection with the Microsoft Cognitive Toolkit.

  • For GPU systems ensure that you have the latest NVIDIA driver

Step 2: Python setup

  • If you do not have an Anaconda installation: install Anaconda Python for Windows. You can follow the standard configuration given in the install program (InstallationType=JustMe; AddToPath=No; RegisterPython=No). In the following we assume you installed Python into C:\local\Anaconda3-4.1.1-Windows-x86_64. If you installed Python in a different directory, please adjust the commands given below accordingly.

  • If you already have a CNTK Python environment (called cntk-py34) you can update it with the latest required packages with the following commands:

cd C:\local\Anaconda3-4.1.1-Windows-x86_64\scripts
conda env update --file c:\local\cntk\scripts\install\windows\conda-windows-cntk-py34-environment.yml --name cntk-py34
activate C:\local\Anaconda3-4.1.1-Windows-x86_64\envs\cntk-py34
  • In your Anaconda installation, create a conda environment (called cntk-py34 here) and activate it by running the following commands from the Windows command shell:
cd C:\local\Anaconda3-4.1.1-Windows-x86_64\scripts
conda env create --file c:\local\cntk\scripts\install\windows\conda-windows-cntk-py34-environment.yml
activate C:\local\Anaconda3-4.1.1-Windows-x86_64\envs\cntk-py34

Step 3: Install CNTK Python Environment

  • From an activated conda environment (see step 3) run: pip install c:\local\cntk\cntk\python\cntk-2.0.beta4.0-cp34-cp34m-win_amd64.whl

Brainscript (optional)

  • From Windows cmd prompt run: setx PATH=c:\local\cntk\cntk;%PATH%

Step 4: Verify the setup (Python)

During this step we describe the basic steps to verify a succesful installation by using the Cognitive Toolkit Python API.

First you need to activate the CNTK environment by opening a standard Windows command prompt (not a Powershell prompt) and running

cd C:\local\Anaconda3-4.1.1-Windows-x86_64\scripts
activate C:\local\Anaconda3-4.1.1-Windows-x86_64\envs\cntk-py34

Note: you will need to do this every time you plan to run CNTK in Python.

This script will also add your CNTK installation to your current PATH environment

  • Run the examples

    Change into the Tutorials\NumpyInterop directory and run the FeedForward example:

cd c:\local\cntk\Tutorials\NumpyInterop
python FeedForwardNet.py

You will see the following output on the console:

Minibatch[   1- 128]: loss = 0.564038 * 3200
Minibatch[ 129- 256]: loss = 0.308571 * 3200
Minibatch[ 257- 384]: loss = 0.295577 * 3200
Minibatch[ 385- 512]: loss = 0.270765 * 3200
Minibatch[ 513- 640]: loss = 0.252143 * 3200
Minibatch[ 641- 768]: loss = 0.234520 * 3200
Minibatch[ 769- 896]: loss = 0.231275 * 3200
Minibatch[ 897-1024]: loss = 0.215522 * 3200
Finished Epoch [1]: loss = 0.296552 * 25600
error rate on an unseen minibatch 0.040000
  • Run Jupyter notebooks

The Toolkit contains several tutorials based on Jupyter notebooks. To use them, execute the following commands:

cd c:\local\cntk\Tutorials
jupyter notebook

This will start a browser with the available notebooks.

Step 5: Verify the setup (BrainScript)

Start a normal Windows command shell, and make sure the CNTK binaries are included in your PATH

set PATH=c:\local\cntk\cntk;%PATH%

Then you can test your installation by:

cd c:\local\CNTK\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.
Clone this wiki locally