Skip to content

Recommended CNTK 2.0 Setup

sayanpa edited this page Oct 22, 2016 · 29 revisions

CNTK V2 Setup and Installation

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

[Note: The CNTK v2 APIs are an alpha release for early users to try and provide feedback on the usability and functional aspects of the API.]

Language Support:

CNTK V2 provides Python and C++ APIs. These APIs enables 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 V2 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 V2 also supports the BrainScript framework.

Binary installation with scripts (recommended)

There are two steps in CNTK V2 binary installation:

Step 1: Prerequisites installation

Step 2: Python (Anaconda environment) installation and CNTK V2 binary package installation

Step 3: Clone from Github examples and tutorials

Please follow the links for:

Installation steps for Windows

Please follow the steps below to install the binaries. The script will additionally clone the CNTK repository into C:\repos\cntk.

Step 1: Prepare to run PowerShell scripts:

  • Downloaded the scripts from here. Unzip/extract in a local folder say C:\scripts. One can create the director by executing mkdir C:\scripts from a Windows command prompt.
  • 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 2: Run PowerShell scripts

Step 3: Run Python setup

Open a windows command window or an anaconda command window

  • Run: [Anaconda install folder root]\Scripts\activate cntk-py34

  • If you want to deploy a new CNTK wheel package at a later time simply re-run:

  • Run: pip install –upgrade [Location of the wheel file]

Step 4: Verify setup

  • Python

Run the examples from inside the [CNTK clone root]/bindings/python directory, to verify your installation. Run python examples/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
  • Brainscript (optional)

Please run the following self contained example:

cd C:\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.

Installation steps for Linux

Please follow the steps below to install the binaries. The script will additionally clone the CNTK repository into /home/[USERNAME]/repos/cntk. Note: we have tested the script on Ubuntu 16.0.4. We first summarize what the script installs for you and sets the environment variables.

Step 1: Prepare to run scripts:

  • Downloaded the scripts from here. Create a directory under /home/[USERNAME] and unzip the scripts in that folder.

Step 2: Run the bash scripts:

Run: bash pycntkv2_linux_install.sh <url-of-wheel>

Step 3: Python updates

  • RUN: source $HOME/anaconda3/bin/activate $HOME/anaconda3/envs/cntk-py34 to activate the python environment after the environment updates are completed.

  • If you want to deploy a new CNTK wheel package at a later time simply re-run: pip install –upgrade [Whl file location]

Step 4: Verify setup

  • Python

Change to where the examples are located and run the python script:

   cd c:\repos\CNTK\bindings\python\examples\NumpyInterop

   python FeedForwardNet.py

A successful implementation should run the python example and you should be able to see output in 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

  • Brainscript (optional)

Please run the following self contained example:

cd C:\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.

The script installs a CNTK Python 3.4 environment with Anaconda 4.1.1 located at $HOME/anaconda3/envs/cntk-py34 with all packages required for CNTK v2 Python and notebooks.

Clone this wiki locally