-
Notifications
You must be signed in to change notification settings - Fork 4.3k
CNTK 2.0 Setup
This page will walk through the manual installation steps for both binary and build from sources.
-
Binary install with manual steps.
-
Build from sources (for developers): We expect individuals interested in contributing to CNTK shall choose this option.
This section is for those individuals who want deploy CNTK V2 binary package following manual steps of Windows and Linux.
[Note: If you previously installed an earlier version of the CNTK 2.0 Python pip package, you can jump to step 3 to update 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:
-
Microsoft MPI of version 7 (7.0.12437.6). Note, that you need run-time (file
MSMpiSetup.exe
) and not SDK. We strongly suggest using version 7 (7.0.12437.6). Using Version 7.1 or any other versions may result in errors -
For GPU systems ensure that you have the latest NVIDIA driver
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
-
Choose a wheel file suitable for your machine
-
From the anaconda / windows shell run:
pip install --upgrade <Location of wheel file>
Brainscript (optional)
-
Download the required binary package from CNTK Releases page and extract it to your machine.
-
From Windows cmd prompt run:
set PATH=%PATH%;[binary folder]\cntk\cntk
Step 4: Download the examples and tutorials
-
Install GIT
-
Clone the CNTK repository (we assume
c:\repos\CNTK
as the repository root) to get the python examples and tutorials and include examples directory inPYTHONPATH
by running:
git clone --recursive https://github.com/Microsoft/CNTK/
cd c:\repos\cntk
git checkout v2.alpha4
setx PYTHONPATH [CNTK repo root]\bindings\python\examples;%PYTHONPATH%
Step 5: 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 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: 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
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 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 CNTK2.0
Python
-
Choose a wheel file suitable for your machine
-
Run
pip install --upgrade <Location of wheel file>
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
Step 4: Download the examples and tutorials
-
Install GIT
-
Clone the CNTK repository (we assume
c:\repos\CNTK
as the repository root) to get the python examples and tutorials and include examples directory inPYTHONPATH
by running:
git clone --recursive https://github.com/Microsoft/CNTK/
cd c:\repos\cntk
git checkout v2.alpha4
setx PYTHONPATH [CNTK repo root]\bindings\python\examples;%PYTHONPATH%
Step 5: 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. Runpython 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.
These steps are intended for contributors and developers. Jump to specific platforms of interest:
-
[Windows]
-
[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 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
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