Skip to content

CNTK 2.0 Setup from Sources

eldakms edited this page Oct 24, 2016 · 13 revisions

This page will walk through the manual installation steps to build CNTK V2 from sources. This is intended for individuals interested in contributing to CNTK shall choose this option.

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

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

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/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: Verify setup

Python

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

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