-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Setup Windows Binary Script
This page will walk you through the process of installing the Microsoft Cognitive Toolkit (CNTK) based on a binary distribution we have prepared and you can download from our website. It is an easy way to get you up-and-running quickly.
These instructions apply to release 2.0.beta7.0.
Note: You can find an overview about all the available installation options for CNTK on [this page] (./Setup-CNTK-on-your-machine).
We will install the CNTK binaries, the CNTK prerequisites, and create a new Python 3.4 environment on your computer. The changes are as much localized as possible to not impact any other installed software. If you have already installed a previous version of CNTK2 on your machine, the script will update this installation. We have tested the Microsoft Cognitive Toolkit on Windows 8.1, Windows 10 and Windows Server 2012 R2.
Once you have download and unpacked the precompiled package, you can run an install script that will perform the following steps:
- If required VS2012 Runtime and VS2013 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-PY34 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-PY34 environment
Please follow these steps:
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.
Once you downloaded the package, for security reasons Windows might try to block execution of any scripts contained in this package. It is easy to mark all the scripts contained in this package as secure:
- Right-click on the downloaded .zip file, choose Properties, and, if near the bottom you see the message "This file came from another computer and might be blocked to help protect this computer", click the checkbox "Unblock" and press "OK".
After you followed the step above, you can now unpack the zip file into a local folder of your choice. We recommend you name the folder according to the version. For example, if you are installing version 2.0Beta5 GPU version, then create a folder, say in c:\local, called c:\local\CNTK-2-0-beta5-0-Windows-64bit-GPU and then unpack into that folder. If you are upgrading, create a new folder with the new name (based on the new version) right along side the folder you created for the older version.
Get the path to your CNTK installation (for example: c:\local\CNTK-2-0-beta5-0-Windows-64bit-GPU ) and create an environment variable named MYCNTKPATH.
set MYCNTKPATH=thePathToCNTKDescribedAbove
.
In the following text we will assume you unpacked the package into %MYCNTKPATH%.
Note: If you have a previous version of CNTK installed on your system, please make sure that you unzip the downloaded package into an empty folder on your machine. Between package versions we might have moved files in the package or even removed files from the package. Unzipping in an empty folder will avoid a mix of files from different CNTK versions.
Step 2 Prepare to run PowerShell scripts
The prepared installation script is written for the Powershell environment.
-
Start Powershell allowing script execution
By default Powershell doesn't allow the execution of any scripts. To allow execution of the installation script start Powershell from a standard Windows command shell by:
start powershell -executionpolicy remotesigned
Step 3 Run the Powershell installation script
Change your current directory into the location of the install script and test the installation script from inside the above opened Powershell environment:
# This will launch the install script in test/demo mode:
cd %MYCNTKPATH%\cntk\Scripts\install\windows
.\install.ps1
Note: If you now receive an errormessage stating that running scripts is disabled on your system, please make sure you followed Step 1 and Step 2 correctly. These two steps are enabling script execution in your created Powershell environment.
The script will inspect your system and determine the pre-requisites which are missing. You will be
notified about the proposed installation steps. At this point you are running in a demo mode -
NO changes to your system are being performed
.
If you are satisfied with the proposed changes, you can proceed to the actual installation.
The installation script supports several command line options. get-help .\install.ps1
will
give you a list over the available option. At this point it is recommended to start the installation
by adding the -Execute
parameter:
.\install.ps1 -execute
The script will download needed components from the web, therefore a connection to the Internet is required. It will execute these components, and according to the setting of UAC (User Account Control) on your system, you will be asked to acknowledge the execution and installtion of these components.
Depending on the speed of your system, your 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 without any progress indication, 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.
You can now close the PowerShell window. All other installation steps or your work with the Microsoft Cognitive Toolkit should be performed from a standard Windows command prompt.
Step 4 Update your GPU Driver
If you have an NVidia graphics card on your system, the card can be used to accelerate the operation of the Microsoft Cognitive Toolkit. Please ensure that you have the latest NVIDIA driver installed. In addition utilization of an NVidia graphics card requires a binary Cognitive Toolkit package supporting GPU or GPU with 1bit-SGD.
Step 5 Verify the setup from Python
During this step we describe the basic steps to verify a successful 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 the batch file created by the installation script (see Step 3).
Note: you will need to do this every time you plan to run CNTK.
In our example it will be:
%MYCNTKPATH%\cntk\scripts\cntkpy34.bat
This script will also add your CNTK installation to your current PATH environment
-
Run an example
Change into the
Tutorials\NumpyInterop
directory and run the FeedForward example:
cd %MYCNTKPATH%\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-2-0-beta5-0-Windows-64bit-GPU\cntk\Tutorials
jupyter notebook
This will start a browser with the available 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:
- First determine your path to Visual studio. For VS2013 it would be something like: "c:\Program Files (x86)\Microsoft Visual Studio 12.0". For VS2105, it would be something like: "c:\Program Files (x86)\Microsoft Visual Studio 14.0". Take that path and create an environment variable named MYVSPATH.
set MYVSPATH=thePathToVSDescribedAbove
. - Next Setup your environment with
%MYVSPATH%\vc\vcvarsall.bat" amd64
. - Next update your PATH environment with
set PATH=%MYCNTKPATH%\cntk\cntk;%PATH%
. - Then open Visual Studio with
%MYVSPATH%\Common7\IDE\devenv.exe
- In VS, go to Tools -> Python Tools -> Python Environments and create a new environment.
- Select Configure from the dropdown menu and set the prefix path to
C:\local\Anaconda3-4.1.1-Windows-x86_64\envs\cntk-py34\
. - Afterwards, click Auto Detect and the rest of the entries will be filled out automatically.
Step 6: Verify the setup for BrainScript
Perform the following command in the CNTK environment command prompt (see previous step):
cd %MYCNTKPATH%\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.