-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Setup Linux Binary Manual
This page will walk you through the process of installing the Microsoft Cognitive Toolkit (CNTK) based on a binary distribution we have prepared and you can download from our website. It is an easy way to get you up-and-running quickly.
We will install the CNTK binaries, the CNTK prerequisites, and create a new Python 3.4 environment on your computer. The changes are as much localized as possible to not impact any other installed software.
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, also called[CNTK repo root]
) to get the Python examples and tutorials and include examples directory inPYTHONPATH
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 the setup (Python)
-
Activate CNTK environment by executing the command specified by the Installation script (see previous step). In our example it will be:
source "/home/username/cntk/activate-cntk"
-
Run the examples from inside the
[CNTK clone root]/bindings/python/examples
directory, to verify your installation. Runpython NumpyInterop/FeedForwardNet.py
. You should see the following output on the console:Minibatch[ 1- 128]: loss = 0.564038 * 3200 Minibatch[ 129- 256]: loss = 0.308571 * 3200 Minibatch[ 257- 384]: loss = 0.295577 * 3200 Minibatch[ 385- 512]: loss = 0.270765 * 3200 Minibatch[ 513- 640]: loss = 0.252143 * 3200 Minibatch[ 641- 768]: loss = 0.234520 * 3200 Minibatch[ 769- 896]: loss = 0.231275 * 3200 Minibatch[ 897-1024]: loss = 0.215522 * 3200 Finished Epoch [1]: loss = 0.296552 * 25600 error rate on an unseen minibatch 0.040000
-
Run the tutorials by executing the following commands:
cd /home/username/repos/CNTK/bindings/python/tutorials jupyter notebook
This will spawn a browser with all available notebooks ready to be run. Should the notebooks fail to execute, run
conda install jupyter
from the activated CNTK environmentcntk-py34
.
Step 6 (Optional): Verify the setup (BrainScript)
Perform the following command in the CNTK environment command prompt (see previous step):
cd /home/username/cntk/Examples/Other/Simple2d/Data/
cntk configFile=../Config/Simple.cntk makeMode=false command=Simple_Demo_Train
The last lines of the CNTK output on the console should look similar to this:
Epoch[10 of 10]-Minibatch[ 361- 370, 92.50%]: CrossEntropyWithSoftmax = 0.15039844 * 250; EvalClassificationError = 0.06800000 * 250; time = 0.0123s; samplesPerSecond = 20374.9
Epoch[10 of 10]-Minibatch[ 371- 380, 95.00%]: CrossEntropyWithSoftmax = 0.13989600 * 250; EvalClassificationError = 0.06800000 * 250; time = 0.0119s; samplesPerSecond = 21082.8
Epoch[10 of 10]-Minibatch[ 381- 390, 97.50%]: CrossEntropyWithSoftmax = 0.16218604 * 250; EvalClassificationError = 0.08400000 * 250; time = 0.0126s; samplesPerSecond = 19887.0
Epoch[10 of 10]-Minibatch[ 391- 400, 100.00%]: CrossEntropyWithSoftmax = 0.13712695 * 250; EvalClassificationError = 0.08400000 * 250; time = 0.0123s; samplesPerSecond = 20353.3
Finished Epoch[10 of 10]: [Training] CrossEntropyWithSoftmax = 0.15792653 * 10000; EvalClassificationError = 0.07570000 * 10000; totalSamplesSeen = 100000; learningRatePerSample = 0.0080000004; epochTime=0.540674s
SGD: Saving checkpoint model '../Output/Models/simple.dnn'
Action "train" complete.
COMPLETED.
If you have an NVidia GPU and installed a GPU build, you can also try this command:
cntk configFile=../Config/Simple.cntk makeMode=false command=Simple_Demo_Train deviceId=0
To validate that the GPU was being used, look for the following line in your output:
Model has 25 nodes. Using GPU 0.