Skip to content

CNTK Binary Download and Configuration

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

The Computational Network 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.

You can install CNTK with in three different ways on Windows and Linux :

TODO

[Note: The CNTK new Python and C++ APIs are a Beta release for early users to try and provide feedback on the usability and functional aspects of the API. CNTK executable with BrainScript suport 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 natively on Windows with Python 3.4.4 and on Linux with Python 3.5. For both the 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 (recommended)

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.

Table of Contents

  1. Windows
  2. Linux

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 Internet connection is required when running the script.

Step 1: Download the appropriate binary package from CNTK Releases page. Unpack the zip file into a local folder.

Step 2: Prepare to run PowerShell scripts:

  • Open PowerShell with administrator priviledges
  • 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 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 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 correct 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

Old: Windows

Download

Download the required binary package from CNTK Releases page and extract it to your machine.

TODO to be moved manual:

Prerequisites

Ensure that the following prerequisites are installed on your system (you will find all required distribution packages, except for NVIDIA drivers in the prerequisites folder of the archive; you may also use the links below):

No further prerequisites are required, but you may want to get yourself familiar with Developer setup for CNTK on Windows

To ensure that CNTK is working properly in your system, you can quickly run Simple2d example from CNTK Examples set. This example trains a simple network and can be directed to use either CPU or GPU, which helps quickly ensure that CNTK is functioning properly:

The following assumes that you extracted the CNTK binaries into the directoriy c:\testcntk. So the c:\testcntk directory will have subdirectories like Examples and license, and the directory c:\testcntk\cntk will contain CNTK.EXE and the other requires CNTK executable files.

  • Open Command Prompt
  • Change into the directory c:\testcntk\Examples\other\simple2d\data and execute the sample from inside that directory with the command below
cd \testcntk\Examples\other\simple2d\data
\testcntk\cntk\CNTK.exe configfile=../config/Simple.cntk

If the sample runs, i.e. if there are no error messages, you will get an output related first to reading the configuration, followed by the output of the actual network training. Running the command a second time will report that the model has already been trained. To perform the training again, you have to specify the makeMode option.

\testcntk\cntk\CNTK.exe configfile=../config/Simple.cntk makeMode=false
Run samples using the CNTK evaluation library

The binary package contains a lot of examples illustrating the usage of CNTK. See the corresponding Examples for details.

Under the Examples\Evaluation folder there are some code samples demonstrating how to use the CNTK Evaluation library in C++ and C#. You need Visual Studio 2013 update 5 for using these samples.

The solution file EvalClients.sln in this folder can be used to build and run samples. It contains two projects:

  • CPPEvalClient: this is the sample for using the C++ eval library. It needs the EvalDll.lib library located in $(SolutionDir)..\..\cntk for building. The sample should be built for the 64-bit target platform and with the release configuration. After a successful build, the executable CPPEvalClient.exe is saved under the $(SolutionDir)..\..$(Platform)\CPPEvalClient.$(Configuration)\ folder, e.g. ..\..\X64\CPPEvalClient.Release. In order to run the program, the directory containing EvalDll.dll and other dependent dlls, usually the $(SolutionDir)..\..\cntk, should be included in the PATH environment variable.
  • CSEvalClient: this is the sample for using the C# eval library. The sample uses the CNTK Evaluation Nuget Package and must be built for the 64-bit target. The executable CSEvalClient.exe is saved under the folder $(SolutionDir)..\..$(Platform)\CSEvalClient.$(Configuration)\ folder, e.g. ..\..\X64\CSEvalClient.Release.

Currently, the CTNK evaluation library and the samples can only be used in CPU only mode. GPU support will be added in future.

If you want to use the CNTK evaluation library in your project, please follow the project settings in EvalClients.sln to configure your own projects.


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 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.

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
sudo ./install-cntk.sh

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 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 running 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 correct 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

OLD: Linux

Download

For Docker use, read the corresponding section. If you don't intend to utilize Docker, please continue reading.

Download the required binary package from CNTK Releases page and extract it to your machine.

Prerequisites

You need to install the following prerequisites:

  • C++ Compiler
  • Open MPI IMPORTANT! We strongly recommend to follow Open MPI installation procedure described by the link above to ensure the correct work of CNTK.
  • For GPU systems ensure that you have the latest NVIDIA driver
Installation

After extracting the archive and installing prerequisites set the following environment variables (we assume that the CNTK archive is extracted to /home/username/cntk):

export PATH=/home/username/cntk/cntk/bin:$PATH
export LD_LIBRARY_PATH=/home/username/cntk/cntk/lib:/home/username/cntk/cntk/dependencies/lib:$LD_LIBRARY_PATH

To quickly verify the correctness of installation use this procedure.

Clone this wiki locally