Skip to content

Setup Windows Python

Wolfgang Manousek edited this page Mar 16, 2017 · 38 revisions

Installing CNTK for Python on Windows

This page will walk you through the process of installing the Microsoft Cognitive Toolkit (CNTK) to use from Python in Windows. If you are looking for any other kind of support to setup a CNTK build environment or installing CNTK on your system, you should go here instead.

Depending on the Python and CNTK version (CPU, GPU, 1bit-SGD) we supply different wheel (.whl) files to install CNTK. Please select the correct installation from the list below, and substitute the name and/or link during the installation.

Python URL
2.7 https://cntk.ai/PythonWheel/CPU-Only/cntk-2.0.beta15.0-cp27-cp27m-win_amd64.whl
https://cntk.ai/PythonWheel/GPU/cntk-2.0.beta15.0-cp27-cp27m-win_amd64.whl
3.4 https://cntk.ai/PythonWheel/CPU-Only/cntk-2.0.beta15.0-cp34-cp34m-win_amd64.whl
https://cntk.ai/PythonWheel/GPU/cntk-2.0.beta15.0-cp34-cp34m-win_amd64.whl
3.5 https://cntk.ai/PythonWheel/CPU-Only/cntk-2.0.beta15.0-cp35-cp35m-win_amd64.whl
https://cntk.ai/PythonWheel/GPU/cntk-2.0.beta15.0-cp35-cp35m-win_amd64.whl

Anaconda3

We have been testing CNTK with Anaconda3 4.1.1 (64-bit) and Python versions 2.7, 3.4 and 3.5. We will support Python 3.6 on Anaconda in the near future. If you do not have a Anaconda3 Python installation, install Anaconda3 4.1.1 Python for Windows (64-bit).

In the following, we assume Anaconda is installed and that it is listed before any other Python installations in your PATH. If you plan on using a GPU enabled version of CNTK, you will need a CUDA 8 compliant graphics card and up-to-date graphics drivers installed on your system.

pip install without an environment

This is the easiest option and the only reason to avoid it is if you require specific versions of certain packages. If you have other packages that require an old version of numpy skip to this section.

First time CNTK installation

If this is the first time you install CNTK then run

c:\> pip install <url>

where <url> is the corresponding wheel file URL in the table on the top of this page. E.g. if you have Python 3.5 run

c:\> pip install https://cntk.ai/PythonWheel/CPU-Only/cntk-2.0.beta15.0-cp35-cp35m-win_amd64.whl

Continue with a quick installation test

Upgrade an existing CNTK installation

If you already have a previous version of CNTK installed, you need to uninstall it

c:\> pip uninstall cntk

As an alternative way you can install a new version of CNTK over your existing installation. It is important to supply the --upgrade and --no-deps options.

c:\> pip install --upgrade --no-deps <url>

where <url> is the corresponding wheel file URL in the table on the top of this page. Once you have completed this upgrade step, you can start working with CNTK in Python or install samples and tutorials.

Quick installation test

A quick test that the installation succeeded can be done by querying the CNTK version:

c:\> python -c "import cntk; print(cntk.__version__)"

You now have successfully installed CNTK, you can start developing / training / evaluating with CNTK in Python!

Continue with installing samples and tutorials

pip install in an environment

In the following we will create a new Python 3.4 environment inside Anaconda called cntk-py34 and will pip-install CNTK into this environment. If you want a different Python version or environment name, please adjust the parameters accordingly.

Open a standard command shell, create the environment, make it active, and pip-install CNTK:

c:\> conda create --name cntk-py34 python=3.4 numpy scipy h5py jupyter
c:\> activate cntk-py34
c:\> pip install https://cntk.ai/PythonWheel/CPU-Only/cntk-2.0.beta15.0-cp34-cp34m-win_amd64.whl

A quick test that the installation succeeded can be done by querying the CNTK version:

c:\> python -c "import cntk; print(cntk.__version__)"

You now have successfully installed CNTK, you can start developing / training / evaluating with CNTK in Python!

Continue with a installing samples and tutorials

Anaconda2

If you require a Python 2.7 root environment, we recommend you install Anaconda2 4.3.0.1 (64-bit).

In the following, we assume Anaconda2 is installed and that it is listed before any other Python installations in your PATH. If you plan on using a GPU enabled version of CNTK, you will need a CUDA 8 compliant graphics card and up-to-date graphics drivers installed on your system.

Anaconda2: CNTK prerequisites

CNTK requires the Visual C++ Redistributable for Visual Studio 2015 installed on your system (in many cases this will already be the case). The installer for the VS2015.3 Runtime (vc_redist.x64.exe) can be downloaded here.

Anaconda2: pip install

The installation steps for CNTK on Anaconda2 are identical to

Just make sure you select Python 2.7 compatible wheel files from the URL table at the top of this page.

Installing Samples and Tutorials

We provide various samples and tutorials with CNTK. After you installed CNTK you can install the samples/tutorials and Jupyter notebooks. If you installed CNTK into a Python environment, make sure you activated the environment before running this command:

c:\> python -m cntk.sample_installer

This will download the samples/tutorials, install the required Python packages, and copy the samples into a directory named CNTK-Samples-VERSION (VERSION is replaced with the actual CNTK version) beneath your current working directory.

You can now follow the standard description to test your installation from Python and run the tutorials or Jupyter notebooks.

Clone this wiki locally