Skip to content

CNTK Binary Download and Configuration

Mark Hillebrand edited this page Oct 25, 2016 · 47 revisions

Microsoft Cognitive Toolkit (CNTK) supports both Windows and Linux 64bit platforms.

We only build release versions after milestones. We encourage users to enlist the source code to get most updated features and bug fixes, and to contribute back to the toolkit community.

This page describes the CNTK binary using the prepackaged scripts, which is the recommended way to get started. See the steps below for instructions

You can also install a CNTK binary download manually or, if you're a developer, build it from sources. This is described here:

[Note: The CNTK new Python and C++ APIs are a Beta release for users to try and provide feedback on the usability and functional aspects of the API. CNTK executable with BrainScript support is in production]

Language Support:

CNTK can act as a library and provides Python and C++ APIs. Additionally, CNTK can be used as a standalone exe with BrainScript. When CNTK is used a library, these APIs enable programmatically defining CNTK models and drive their training/evaluation, using either built-in data readers or user supplied data in native Python numpy/C++ arrays.

  • Python:
    • CNTK with Python APIs is supported for Python 3.4 for Windows and Linux. For both platforms one can create a 3.4.4 Python environment within any Anaconda (Python 2.7 or 3.x version).
  • Brainscript:
    • CNTK also supports the BrainScript framework.

Binary installation with scripts

Please follow the links for:

Note: The script installs a CNTK Python 3.4 environment with Anaconda 4.1.1 located at C:\local\Anaconda3-4.1.1-Windows-x86_64\envs\cntk-py34 (Windows) or ~/anaconda3/envs/cntk-py34/ (Linux) with all packages required for CNTK v2 Python and notebooks.

Installation steps for Windows

Please follow the steps below to install the binaries. The installation script will additionally download the necessary dependencies and clone the CNTK repository, so an Internet connection is required when running the script.

Step 1: Download the appropriate binary package from CNTK Releases page. Windows might try to block script execution from a downloaded package from the Internet. Right-click on the downloaded .zip file, choose Properties, and, if near the bottom it says "This file came from another computer and might be blocked to help protect this computer",, click the checkobx "Unblock" and and "OK". Only then unpack the zip file into a local folder.

Step 2: Prepare to run PowerShell scripts:

  • Open PowerShell with administrator privileges
  • Click on Windows Start
  • Search for Windows PowerShell (see below), Right click on the icon and select Run as administrator

  • Type and run: set-executionpolicy -executionpolicy unrestricted. Upon being prompted, select A

  • Close the PowerShell window
  • Start a new Windows PowerShell application similar to previous step (not in Administrator mode)

Step 3: Run the PowerShell Installation script

Below we assume that you have unzipped the CNTK Binary package to c:\local\.

  • Run:
cd c:\local\cntk\Scripts\windows
.\install.ps1

The script will tell you what changes it is about to do on your machine and will emulate the installation steps. No actual changes will be done to your machine at this point.

If you are satisfied with the proposed changes, proceed to the actual installation. We recommend closing all running programs to avoid conflicts with the different installation procedures to be executed. Start the installation by running:

.\install.ps1 -execute

IMPORTANT! Expect multiple prompts from UAC (User Account Control) asking your agreement to run certain installation programs.

Because the script needs to download some installation packages from remote locations expect, that running it will take some time (expect at least 20 minutes if none of the required pre-requisites are detected on your system).

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.

  • Close the PowerShell window.

Step 4: Verify the setup (Python)

Open Windows command prompt and activate the CNTK Python environment by executing the batch file specified by the Installation script (see previous step). In our example it will be:

C:\local\cntk\scripts\cntkpy34.bat

Run the following commands:

cd c:\repos\CNTK\bindings\python
python examples/NumpyInterop/FeedForwardNet.py

If everything works correctly you should get a console output like the one below:

Minibatch: 0, Train Loss: 0.6915470886230469, Train Evaluation Criterion: 0.52
Minibatch: 60, Train Loss: 0.6610990142822266, Train Evaluation Criterion: 0.56
Minibatch: 120, Train Loss: 0.31225751876831054, Train Evaluation Criterion: 0.2
Minibatch: 180, Train Loss: 0.1848754119873047, Train Evaluation Criterion: 0.08
Minibatch: 240, Train Loss: 0.19827106475830078, Train Evaluation Criterion: 0.08
Minibatch: 300, Train Loss: 0.16531991958618164, Train Evaluation Criterion: 0.04
Minibatch: 360, Train Loss: 0.8258456420898438, Train Evaluation Criterion: 0.28
Minibatch: 420, Train Loss: 0.31327741622924804, Train Evaluation Criterion: 0.16
Minibatch: 480, Train Loss: 0.14627487182617188, Train Evaluation Criterion: 0.04
Minibatch: 540, Train Loss: 0.19005121231079103, Train Evaluation Criterion: 0.12
Minibatch: 600, Train Loss: 0.15139059066772462, Train Evaluation Criterion: 0.04
Minibatch: 660, Train Loss: 0.10627300262451173, Train Evaluation Criterion: 0.04
Minibatch: 720, Train Loss: 0.33113689422607423, Train Evaluation Criterion: 0.12
Minibatch: 780, Train Loss: 0.3315776443481445, Train Evaluation Criterion: 0.12
Error: 0.120000

Step 5 (Optional): Verify the setup (BrainScript)

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

cd C:\repos\CNTK\Examples\Other\Simple2d\Data
  • Testing with CPU: Run the following command
cntk configFile=../Config/Simple.cntk makeMode=false 1> out.txt 2>&1

Look for the string Builder Using in the resulting file out.txt. You should be able to find this line:

SimpleNetworkBuilder Using CPU
  • Testing with GPU: Run the following command
cntk configFile=../Config/Simple.cntk deviceId=auto makeMode=false 1> out.txt 2>&1

Look for the string Builder Using in the resulting file out.txt. You should be able to find a line like this:

SimpleNetworkBuilder Using GPU 0

Installation steps for Linux

Please follow the steps below to install the binaries. The installation script will additionally download the necessary dependencies and clone the CNTK repository, so an Internet connection is required when running the script.

The script was tested on Ubuntu 14.04 and 16.04 only. It will generate a warning about possible failures if run on any other platform.

Step 1: Download the appropriate binary package from CNTK Releases page. Unpack the tar.

Note: Choose a GPU binary download only if your machine has an NVidia GPU.

Step 2: Run bash Installation script

Below we assume that you have unpacked the CNTK Binary package to /home/username.

  • Run:
cd /home/username/cntk/Scripts/linux
./install-cntk.sh

The script will download some installation packages from remote locations. Expect that running it will take some time (expect at least 20 minutes on Ubuntu 16.04 and even more on Ubuntu 14.04 if none of the required pre-requisites are detected on your system).

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

Step 3: Verify the setup (Python)

Activate CNTK Python environment by executing the command specified by the Installation script (see previous step). In our example it will be:

source "/home/username/cntk/activate-cntk"

Run the following commands:

cd /home/username/repos/cntk/bindings/python/
python examples/NumpyInterop/FeedForwardNet.py

If everything works correctly you should get a console output like the one below:

Minibatch: 0, Train Loss: 0.8206577301025391, Train Evaluation Criterion: 0.52
Minibatch: 60, Train Loss: 0.6785884857177734, Train Evaluation Criterion: 0.56
Minibatch: 120, Train Loss: 0.3107606506347656, Train Evaluation Criterion: 0.2
Minibatch: 180, Train Loss: 0.18287521362304687, Train Evaluation Criterion: 0.08
Minibatch: 240, Train Loss: 0.1765269470214844, Train Evaluation Criterion: 0.08
Minibatch: 300, Train Loss: 0.1621664810180664, Train Evaluation Criterion: 0.04
Minibatch: 360, Train Loss: 0.7618668365478516, Train Evaluation Criterion: 0.28
Minibatch: 420, Train Loss: 0.3137692451477051, Train Evaluation Criterion: 0.16
Minibatch: 480, Train Loss: 0.14263723373413087, Train Evaluation Criterion: 0.04
Minibatch: 540, Train Loss: 0.1877730369567871, Train Evaluation Criterion: 0.12
Minibatch: 600, Train Loss: 0.1465793228149414, Train Evaluation Criterion: 0.04
Minibatch: 660, Train Loss: 0.10579365730285645, Train Evaluation Criterion: 0.04
Minibatch: 720, Train Loss: 0.33099319458007814, Train Evaluation Criterion: 0.12
Minibatch: 780, Train Loss: 0.3307284164428711, Train Evaluation Criterion: 0.12
Error: 0.120000

Step 4 (Optional): Verify the setup (BrainScript)

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

cd /home/username/cntk/Examples/Other/Simple2d/Data/
  • Testing with CPU: Run the following commands
cntk configFile=../Config/Simple.cntk makeMode=false &> out
cat out | grep Builder

You should get the following output:

    SimpleNetworkBuilder = [
SimpleNetworkBuilder Using CPU
  • Testing with GPU: Run the following command
cntk configFile=../Config/Simple.cntk deviceId=auto makeMode=false &> out
cat out | grep Builder

Look for the string Builder Using in the resulting file out.txt. You should get an output like this:

    SimpleNetworkBuilder = [
SimpleNetworkBuilder Using GPU 0
Clone this wiki locally