Skip to content

CNTK 2.0 Setup from Sources

sayanpa edited this page Oct 24, 2016 · 13 revisions

This page will walk through the manual installation steps for build from sources (for developers): We expect individuals interested in contributing to CNTK shall choose this option.

These steps are intended for contributors and developers. Jump to specific platforms of interest:

  1. Windows

  2. Linux

Steps for Windows

Step 1: Install pre-requisites and build dependencies

  • If you do not have CNTK development environment already setup on your machine, follow the instructions on CNTK github (Setting up CNTK on Windows).
  • Please follow the instructions for Steps 4 here to clone the repository.

Step 2: Build CNTK

  • Build CNTK (Release version).

Step 3: Build Python

  • Install SWIG 3.0.10:

  • 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 4: Uninstall previous CNTK 2.0 package

  • 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 5: Building python package

  • Follow the instructions here for building python APIs locally or a wheel package for distribution.

Step 6: Testing

  • Please follow the instructions for Steps 5 here to run the examples against your build.

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

Steps for Linux

Step 1: Install pre-requisites and build dependencies

  • If you do not have CNTK development environment already setup on your machine, follow the instructions on (Setting up CNTK on Linux).
  • Please follow the instructions for Steps 4 here to clone the repository.

Step 2: Build CNTK

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

Step 3: Build Python APIs

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

  • 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 4: Uninstall previous CNTK 2.0 package

  • 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 5: Build Python Package

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

Step 6: Testing

  • Run the examples to ensure the build worked
export PYTHONPATH=[CNTK clone root]/bindings/python:$PYTHONPATH

python examples/NumpyInterop/FeedForwardNet.py
  • 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

Clone this wiki locally