Skip to content

CNTK 2.0 Setup

sayanpa edited this page Oct 22, 2016 · 24 revisions

Step-by-Step CNTK V2 installation

This page will walk through the manual installation steps for both binary and build from sources.

Option 2. Binary install with manual steps.

Option 3. Build from sources (for developers): We expect individuals interested in contributing to CNTK shall choose this option.

Option 2: Binary installation (manual steps)

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

Steps for Windows

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

Step 1: Install pre-requisites

CNTK V2 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 Anaconda environment: install Anaconda Python for Windows

If you already have existing Anaconda env or after your have installed the environment above: Create a conda environment, activate the cntk-py34 environment, 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
  activate cntk-py34
  python -m pip install --upgrade pip**

  ```

Step 3: Install CNTK

  • Python

Install the CNTK 2.0 alpha2 pip package

From the anaconda / windows shell run: pip install --upgrade <Location of wheel file>

  • Brainscript (optional)

Step 5: Verify set up

-Python

Install GIT and clone the CNTK repository to get the python examples and tutorials by running:

git clone

Include the examples directory in PYTHONPATH:

Run: setx PYTHONPATH [CNTK repo root]\bindings\python\examples;%PYTHONPATH%

Steps for Linux

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

Step 1:

Follow the instructions on the CNTK Github Wiki page CNTK Binary Download and Configuration to install the necessary prerequisites for running CNTK binary installation on your machine.

[Note: Please only follow the prerequisites section – download of the binaries is not required since they are part of the pip package you will install in the next step.]

Step 2:

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

  ```
  conda create --name cntk-py34 python=3.4.3 numpy scipy jupyter matplotlib
  activate cntk-py34
  ```

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

Step 3:

Upgrade pip: python -m pip install --upgrade pip

[Note: If you get an error about insufficient permissions, run the command from an elevated command prompt]

Step 4:

Install the CNTK 2.0 alpha2 pip package

Run pip install --upgrade <Location of wheel file>

Step 5: [Optional]

You may run the Python test included in the CNTK module

pip install pytest

python -c "import cntk, os; print(os.path.dirname(os.path.abspath(cntk.__file__)))"

pytest [the directory output by the previous command]

Step 6:

Get a clone (or update your existing clone) of the CNTK repository (master branch) to get the Python examples and training data files used in these examples.

Step 7:

Include the examples directory in PYTHONPATH: Run: export PYTHONPATH=[CNTK repo root]/bindings/python/examples:$PYTHONPATH

Build from sources

These steps are intended for contributors and developers.

On Windows

Step 1:

If you do not have CNTK development environment already setup on your machine, follow the instructions on CNTK github (Setting up CNTK on Windows).

Step 2:

Build CNTK (Release version).

Step 3:

Install SWIG 3.0.10:

Step 4:

Install Anaconda recommended (Anaconda Python 3.4) or create a Python 3.4.3 environment within your existing Python Anaconda or miniconda installation using the following commands:

  ```
  conda create --name cntk-py34 python=3.4.3 numpy scipy jupyter matplotlib

  activate cntk-py34
  ```

[Note: Make sure that the python version installed above is what you use for the remainder of the instructions.]

Step 5:

If you previously installed any version of the CNTK 2.0 pip-package on your machine, uninstall it by running: pip uninstall cntk-py34

Step 6:

Follow the instructions in “section # a” of [CNTK clone root]/bindings/python/readme.txt for setup. Then run the examples from inside the [CNTK clone root]/bindings/python directory, to verify your installation:

Run python examples/NumpyInterop/feedforwardNet.py

Step 7:

If your build and setup succeeded, 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

Note: If you see an error saying "RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9", your numpy version is outdated and needs to be updated, run: pip install --upgrade numpy

On Linux

Step 1:

If you do not have CNTK development environment already setup on your machine, follow the instructions on CNTK github (Setting up CNTK on Linux).

Step 2:

Build of CNTK (Release flavor) with the GPU SKU.

Step 3:

Install SWIG by running the script: [CNTK clone root]/bindings/python/cntk/swig_install.sh

Step 4:

Install Anaconda python 3.5 Create a Python 3.4.3 environment in your existing Python 3.5 anaconda or miniconda installation using the following commands:

conda create --name cntk-py34 python=3.4.3 numpy scipy jupyter matplotlib

activate cntk-py34

[Note: Make sure that the python version installed above is what you use for the remainder of the instructions.]

Step 5:

If you previously installed any version of the CNTK 2.0 pip-package on your machine, uninstall it by running: pip uninstall cntk-py34

Step 6:

Run the following set of commands:

cd [CNTK clone root]/bindings/python]

swig -version (Make sure swig with version >= 3.0.10 is in path)

python ./setup.py build_ext (Ignore any warnings reported by this step - they are currently expected)

cp ./build/lib.linux-x86_64-3.5/_cntk_py.cpython-35m-x86_64-linux-gnu.so .

export PYTHONPATH=[CNTK clone root]/bindings/python:$PYTHONPATH

python examples/NumpyInterop/FeedForwardNet.py

Step 7:

If your build and setup succeeded, 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

Note: If you see an error saying "RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9", your numpy version is outdated and needs to be updated, run: pip install --upgrade numpy

Download instructions for the previous CNTK installs: CNTK Binary Download and Configuration to install the necessary prerequisites for running CNTK binary installation on your machine.

Clone this wiki locally