Skip to content

CNTK Binary Download and Manual Installation

sayanpa edited this page Oct 28, 2016 · 8 revisions

Step-by-Step installation

This page will walk through the manual installation steps for binary install one component at a time. This is intended for those users who want to have a customized installation.

If you are a developer intending to contribute to CNTK please follow the instructions to build from sources, Windows or Linux.

Binary installation (manual steps)

This section is for those individuals who want deploy CNTK binary package following manual steps of Windows and Linux.

Steps for Windows

[Note: 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

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

Step 2: Python setup

  • If you do not have an Anaconda installation: install Anaconda Python for Windows

  • In your Anaconda installation, create a conda environment (called cntk-py34 here), activate it, and update the pip version by running the following commands from the anaconda / windows shell:

conda create --name cntk-py34 python=3.4.3 numpy scipy jupyter matplotlib pillow
activate cntk-py34
python -m pip install --upgrade pip**

Step 3: Install CNTK

Python

  • From the Anaconda / windows shell run: pip install --upgrade .\cntk\python\cntk-2.0.beta1.0-cp34-cp34m-win_amd64.whl

Brainscript (optional)

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

  • From Windows cmd prompt run: set PATH=%PATH%;[binary folder]\cntk\cntk

Step 4: Download the examples and tutorials

  • Install GIT

  • Clone the CNTK repository (we assume c:\repos\CNTK as the repository root) to get the Python examples and tutorials and include examples directory in PYTHONPATH by running:

git clone --recursive https://github.com/Microsoft/CNTK/
cd c:\repos\cntk 
git checkout v2.0.beta1.0
set PYTHONPATH=[CNTK repo root]\bindings\python\examples;%PYTHONPATH%

Step 5: Verify setup

Python

  • Activate the CNTK-py34 environment by running: activate CNTK-py34.

  • Run the examples from inside the [CNTK clone root]\bindings\python\examples directory, to verify your installation. Run python NumpyInterop\FeedForwardNet.py. You should following output on the console:

Minibatch: 0, Train Loss: 0.7915553283691407, Train Evaluation Criterion: 0.48

Minibatch: 20, Train Loss: 0.6266774368286133, Train Evaluation Criterion: 0.48

Minibatch: 40, Train Loss: 1.0378565979003906, Train Evaluation Criterion: 0.64

Minibatch: 60, Train Loss: 0.6558118438720704, Train Evaluation Criterion: 0.56
  • Run the tutorials by executing the following commands
cd c:\repos\CNTK\bindings\python\tutorials
jupyter notebook

This should spawn a browser with all available notebooks ready to be run. Should the notebooks fail to execute, additionally run conda install jupyter from the activated CNTK environment cntk-py34.

Brainscript (optional)

To ensure that CNTK with Brainscript is working properly on your system, you can quickly run the following self-contained 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:

cd C:\repos\CNTK\Examples\Other\Simple2d

CNTK configFile=Config/Simple.cntk currentDirectory=Data

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.

CNTK configFile=Config/Simple.cntk currentDirectory=Data 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 CNTK 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.

Steps for Linux

[Note: If you previously installed an earlier version of the CNTK Python package, you can skip steps 1 through 3 below and directly jump to step 4 to update your existing CNTK package installation from your Python 3.4 environment]

Step 1: Download and install pre-requisites

Docker users please follow the instructions here. Others please continue reading.

CNTK V2 on Linux requires the following prerequisites to be installed from the links below:

  • 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

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

Step 2: Python setup

  • If you do not have Anaconda environment: install Anaconda Python 3.5 for Linux

  • If you already have existing Anaconda env or after your have installed the environment above, create a conda environment, upgrade the pip package by running (if needed under elevated command prompt)

conda create --name cntk-py34 python=3.4.3 numpy scipy jupyter matplotlib pillow
source activate cntk-py34
python -m pip install --upgrade pip

Note: Make sure that this Python version above is what you use for the remainder of the instructions.

Step 3: Install CNTK

Python

  • Run pip install --upgrade ./cntk/python/cntk-2.0.beta1.0-cp34-cp34m-linux_x86_64.whl

Brainscript

  • Set the following environment variables (we assume that the CNTK archive is extracted to /home/username/cntkbin):
export PATH=/home/username/cntkbin/cntk/bin:$PATH
export LD_LIBRARY_PATH=/home/username/cntkbin/cntk/lib:/home/username/cntkbin/cntk/dependencies/lib:$LD_LIBRARY_PATH

Note: If you've built openmpi yourself (for example, on Ubuntu 14), make sure to add its library directory to LD_LIBRARY_PATH as well:

export LD_LIBRARY_PATH=[path-to-your-openmpi-installation]/lib:$LD_LIBRARY_PATH

Step 4: Download the examples and tutorials

  • Install GIT

  • Clone the CNTK repository (we assume $HOME/repos/CNTK as the repository root) to get the Python examples and tutorials and include examples directory in PYTHONPATH by running:

cd $HOME/repos
git clone --recursive https://github.com/Microsoft/CNTK
cd CNTK
git checkout v2.0.beta1.0
export PYTHONPATH=$PWD/bindings/python/examples:$PYTHONPATH

Step 5: Verify setup

Python

  • Activate the python environment by running: source "/home/username/cntk/activate-cntk"

  • Run the examples from inside the [CNTK clone root]/bindings/python/examples directory, to verify your installation. Run python NumpyInterop/FeedForwardNet.py. You should see the following output on the console:

Minibatch: 0, Train Loss: 0.7915553283691407, Train Evaluation Criterion: 0.48

Minibatch: 20, Train Loss: 0.6266774368286133, Train Evaluation Criterion: 0.48

Minibatch: 40, Train Loss: 1.0378565979003906, Train Evaluation Criterion: 0.64

Minibatch: 60, Train Loss: 0.6558118438720704, Train Evaluation Criterion: 0.56
  • Run the tutorials by executing the following commands:
cd /home/username/repos/CNTK/bindings/python/tutorials
jupyter notebook

This should spawn a browser with all available notebooks ready to be run. Should the notebooks fail to execute, additionally run conda install jupyter from the activated CNTK environment cntk-py34.

Brainscript (optional)

  • Please run the following self contained example:
cd /home/username/repos/CNTK/Examples/Other/Simple2d

cntk configFile=Config/Simple.cntk currentDirectory=Data

You should be able to see the results getting printed on the console.

Clone this wiki locally