Followed this manual instruction since I have Anaconda already installed. Be very careful to install all required binaries:

I forgot to install MPI and later when import cntk it failed loading the _cntk_py.pyd module, costing me a lot of time. This error can also happen if you installed a wrong target version of CNTK, e.g., you installed CNTK GPU on a host without GPU.

Then create a conda environment for it:

1
2
3
conda create --name cntk python=3.4.3 anaconda
activate cntk
python -m pip install --upgrade pip # This is really optional to me

See Anaconda python management for how to create conda environment.

Now pip install from github here. There're three choices:

  • CPU only
  • GPU
  • GPU with 1bit SGD

Note that the python version needs to match your python installation.

I tried the CPU only and the GPU with 1bit SGD, seems to work on my Surface Book with standalone GPU.

Now to verify it works, fire up a conda commandline and:

1
2
3
4
5
activate cntk-py34
python

# now in python:
>> import cntk # this should succeed!

Notes on Anaconda environment

to display conda environment information

conda info --all

IDE setup

Best autocompletion support for Python that I've seen so far is PyCharm. Python Tools for Visual Studio (PTVS), for example, is not able to infer function signature on cntk.ops.input_variable and others. Install the free PyCharm community edition is sufficient. To let PyCharm use the Anaconda CNTK environment:

  1. find the python executable python by using conda info --all.
  2. in PyCharm -> settings -> project -> project interpreter -> "add local", put in the desired python executable path
  3. note that CNTK relies on a bunch of environment variables to work, e.g., MSMPI_LIB32, MSMPI_LIB64, so always launch PyCharm from the anaconda console to ensure necessary environment variables are inherited by the IDE. If this is not set up properly, interpreter throws when import cntk, complaining module cannot be loaded.

For the convinience of launch PyCharm from commandline, I added PyCharm to PATH.

CNTK development workflow

  1. launch Anaconda console
  2. activate cntk-py34
  3. (optional) launch powershell
  4. launch IDE from anaconda environment