Microsoft Cognitive Toolkit (CNTK) - Getting Started


Here, we will understand about the installation of CNTK on Windows and on Linux. Moreover, the chapter explains installing CNTK package, steps to install Anaconda, CNTK files, directory structure and CNTK library organisation.


In order to install CNTK, we must have Python installed on our computers. You can go to the link and select the latest version for your OS, i.e. Windows and Linux/Unix. For basic tutorial on Python, you can refer to the link

Python Downloads

CNTK is supported for Windows as well as Linux so we will walk through both of them.

Installing on Windows

In order to run CNTK on Windows, we will be using the Anaconda version of Python. We know that, Anaconda is a redistribution of Python. It includes additional packages like Scipy andScikit-learn which are used by CNTK to perform various useful calculations.

So, first let see the steps to install Anaconda on your machine −

Step 1−First download the setup files from the public website

Step 2 − Once you downloaded the setup files, start the installation and follow the instructions from the link

Step 3 − Once installed, Anaconda will also install some other utilities, which will automatically include all the Anaconda executables in your computer PATH variable. We can manage our Python environment from this prompt, can install packages and run Python scripts.

Installing CNTK package

Once Anaconda installation is done, you can use the most common way to install the CNTK package through the pip executable by using following command −

pip install cntk

There are various other methods to install Cognitive Toolkit on your machine. Microsoft has a neat set of documentation that explains the other installation methods in detail. Please follow the link

Installing on Linux

Installation of CNTK on Linux is a bit different from its installation on Windows. Here, for Linux we are going to use Anaconda to install CNTK, but instead of a graphical installer for Anaconda, we will be using a terminal-based installer on Linux. Although, the installer will work with almost all Linux distributions, we limited the description to Ubuntu.

So, first let see the steps to install Anaconda on your machine −

Steps to install Anaconda

Step 1 − Before installing Anaconda, make sure that the system is fully up to date. To check, first execute the following two commands inside a terminal −

sudo apt update
sudo apt upgrade

Step 2 − Once the computer is updated, get the URL from the public website for the latest Anaconda installation files.

Step 3 − Once URL is copied, open a terminal window and execute the following command −

wget -0 url SHAPE \* MERGEFORMAT 

|                     }

Replace the url placeholder with the URL copied from the Anaconda website.

Step 4 − Next, with the help of following command, we can install Anaconda −

sh ./

The above command will by default install Anaconda3 inside our home directory.

Installing CNTK package

Once Anaconda installation is done, you can use the most common way to install the CNTK package through the pip executable by using following command −

pip install cntk

Examining CNTK files & directory structure

Once CNTK is installed as a Python package, we can examine its file and directory structure. It’s at C:\Users\\Anaconda3\Lib\site-packages\cntk, as shown below in screenshot.

Files and Directory Structure

Verifying CNTK installation

Once CNTK is installed as a Python package, you should verify that CNTK has been installed correctly. From Anaconda command shell, start Python interpreter by entering ipython. Then, import CNTK by entering the following command.

import cntk as c

Once imported, check its version with the help of following command −


The interpreter will respond with installed CNTK version. If it doesn’t respond, there will be a problem with the installation.

The CNTK library organisation

CNTK, a python package technically, is organised into 13 high-level sub-packages and 8 smaller sub-packages. Following table consist of the 10 most frequently used packages:

Sr.No Package Name & Description

Contains functions for reading data. For example: next_minibatch()



Contains high-level functions for creating neural networks. For example: Dense()



Contains functions for training. For example: sgd()



Contains functions to measure training error. For example: squared_error()



Contains functions to measure model error. For example: classificatoin_error



Contains low-level functions for creating neural networks. For example: tanh()



Contains functions to generate random numbers. For example: normal()



Contains training functions. For example: train_minibatch()



Contains model parameter initializers. For example: normal() and uniform()



Contains low-level constructs. For example: Parameter() and Variable()

Useful Video Courses


Microsoft Azure Tutorials Step by Step

16 Lectures 11.5 hours



Microsoft Excel Masterclass for Business Managers

33 Lectures 3 hours

Abhishek And Pukhraj


Zero to Hero in Microsoft Excel: Complete Excel guide

33 Lectures 5.5 hours

Abhishek And Pukhraj


Advanced Microsoft Word 2013 Tutorial

40 Lectures 6.5 hours

Syed Raza


Big Data Analytics on Microsoft AZURE

18 Lectures 1.5 hours

Pranjal Srivastava, Harshit Srivastava