CNTK installation and IDE setup
Followed this manual instruction since I have Anaconda already installed. Be very careful to install all required binaries:
- Visual C++ Redistributable Package for Visual Studio 2013
- Visual C++ Redistributable Package for Visual Studio 2012
- MPI
- Visual C++ compiler - install this from visual studio, otherwise it complains "Microsoft Visual C++ 14.0 is required" during
pip install
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 | conda create --name cntk python=3.4.3 anaconda |
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 | activate cntk-py34 |
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:
- find the python executable python by using
conda info --all
. - in PyCharm -> settings -> project -> project interpreter -> "add local", put in the desired python executable path
- 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 whenimport cntk
, complaining module cannot be loaded.
For the convinience of launch PyCharm from commandline, I added PyCharm to PATH
.
CNTK development workflow
- launch Anaconda console
activate cntk-py34
- (optional) launch powershell
- launch IDE from anaconda environment