Skip to content

CNTK 2.0 Python API

sayanpa edited this page Oct 23, 2016 · 103 revisions

Python API build instructions

This file contains step-by-step instructions on how to build the Python API for CNTK on Windows.

Current build is supported for py3.4 (with numpy and scipy) on 64-bit platform. Python 2.7 build from souce is cuurently not supported.

Build steps

Step 1: Set up compiler and its variant by calling:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall" amd64  
set MSSdk=1  
set DISTUTILS_USE_SDK=1  

Step 2: Swig setup

Make sure swig.exe is in your path. For example, if SWIG is installed to c:\local\swigwin-3.0.10, run the following:

set PATH=c:\local\swigwin-3.0.10;%PATH%  

Step 3: Local build

  • Build / generate the pyd file by running: `
python .\setup.py build_ext --inplace --force 
  • add to PATH the path to CNTK dlls (e.g. in ....\x64\Release)
set PATH=%CD%\..\..\x64\Release;%PATH%  
  • Add to PYTHONPATH the local path and the path to the Python examples
set PYTHONPATH=%CD%;%CD%\examples;%PYTHONPATH%  

-Test by running any of the examples or running py.test from inside the cntk\tests or cntk\ops\tests directories.

Step 4: Build a package

  • Install the twine and wheel packages by running:
  pip install twine wheel  
  • Run the following (note: --inplace not required when packaging):
python .\setup.py build_ext bdist_wheel  
  • Put the wheel file on some http server

  • From your machine, run pip install

pip install http://your-url:your-port/cntk-0.0.0-cp34-cp34m-win_amd64.whl
  • Check that it is loaded correctly by running
python  
>>> import cntk
Clone this wiki locally