-
Notifications
You must be signed in to change notification settings - Fork 4.3k
CNTK Binary Download and Configuration
Microsoft Cognitive Toolkit (CNTK) supports both Windows and Linux 64bit platforms.
We only build release versions after milestones. We encourage users to enlist the source code to get most updated features and bug fixes, and to contribute back to the toolkit community.
This page describes the CNTK binary using the prepackaged scripts, which is the recommended way to get started. See the steps below for instructions
You can also install a CNTK binary download manually or, if you're a developer, build it from sources. This is described here:
-
Binary install with manual steps: For those who need custom installation (with setting being different from the pre-packaged scripts).
-
Build from sources: Those interested in contributing to CNTK.
[Note: The CNTK new Python and C++ APIs are a Beta release for users to try and provide feedback on the usability and functional aspects of the API. CNTK executable with BrainScript support is in production]
Language Support:
CNTK can act as a library and provides Python and C++ APIs. Additionally, CNTK can be used as a standalone exe with BrainScript. When CNTK is used a library, these APIs enable programmatically defining CNTK models and drive their training/evaluation, using either built-in data readers or user supplied data in native Python numpy/C++ arrays.
-
Python:
- CNTK with Python APIs is supported for Python 3.4 for Windows and Linux. For both platforms one can create a 3.4.4 Python environment within any Anaconda (Python 2.7 or 3.x version).
-
Brainscript:
- CNTK also supports the BrainScript framework.
Please follow the links for:
Note: The script installs a CNTK Python 3.4 environment with Anaconda 4.1.1 located at C:\local\Anaconda3-4.1.1-Windows-x86_64\envs\cntk-py34
(Windows) or ~/anaconda3/envs/cntk-py34/
(Linux) with all packages required for CNTK v2 Python and notebooks.
Please follow the steps below to install the binaries. The installation script will additionally download the necessary dependencies and clone the CNTK repository, so an Internet connection is required when running the script.
Step 1: Download the appropriate binary package from CNTK Releases page. Windows might try to block script execution from a downloaded package from the Internet. Right-click on the downloaded .zip file, choose Properties, and, if near the bottom it says "This file came from another computer and might be blocked to help protect this computer",, click the checkobx "Unblock" and and "OK". Only then unpack the zip file into a local folder.
Step 2: Prepare to run PowerShell scripts:
- Open PowerShell with administrator privileges
- Click on Windows Start
- Search for Windows PowerShell (see below), Right click on the icon and select Run as administrator
- Type and run:
set-executionpolicy -executionpolicy unrestricted
. Upon being prompted, select A
- Close the PowerShell window
- Start a new Windows PowerShell application similar to previous step (not in Administrator mode)
Step 3: Run the PowerShell Installation script
Below we assume that you have unzipped the CNTK Binary package to c:\local\
.
- Run:
cd c:\local\cntk\Scripts\windows
.\install.ps1
The script will tell you what changes it is about to do on your machine and will emulate the installation steps. No actual changes will be done to your machine at this point.
If you are satisfied with the proposed changes, proceed to the actual installation. We recommend closing all running programs to avoid conflicts with the different installation procedures to be executed. Start the installation by running:
.\install.ps1 -execute
IMPORTANT! Expect multiple prompts from UAC (User Account Control) asking your agreement to run certain installation programs.
Because the script needs to download some installation packages from remote locations expect, that running it will take some time (expect at least 20 minutes if none of the required pre-requisites are detected on your system).
By the end of the successful setup the script will inform you about the location of the CNTK Python environment batch file and of the location of CNTK Python examples.
-
Close the PowerShell window.
-
For GPU Systems: Please ensure that you have the latest NVIDIA driver
Step 4: Verify the setup (Python)
- Activate CNTK environment by opening Windows command prompt and activate the CNTK Python environment by executing the batch file specified by the installation script (see previous step). In our example it will be:
c:\local\cntk\scripts\cntkpy34.bat
Please note, if you run the batch file CNTKPY34.BAT, it will add CNTK at the end of your current path. If you have previous versions of CNTK installed on your machine, you might want to remove them from the path environment.
-
Run the examples from inside the
[CNTK clone root]\bindings\python\examples
directory, to verify your installation. Runpython NumpyInterop/FeedForwardNet.py
. You should see the following output on the console:
Minibatch: 0, Train Loss: 0.6915470886230469, Train Evaluation Criterion: 0.52
Minibatch: 120, Train Loss: 0.31225751876831054, Train Evaluation Criterion: 0.2
Minibatch: 240, Train Loss: 0.19827106475830078, Train Evaluation Criterion: 0.08
Minibatch: 360, Train Loss: 0.8258456420898438, Train Evaluation Criterion: 0.28
Minibatch: 480, Train Loss: 0.14627487182617188, Train Evaluation Criterion: 0.04
Minibatch: 600, Train Loss: 0.15139059066772462, Train Evaluation Criterion: 0.04
Minibatch: 720, Train Loss: 0.33113689422607423, Train Evaluation Criterion: 0.12
Error: 0.120000
- Run the tutorials by executing the following commands:
cd c:\repos\CNTK\bindings\python\tutorials
jupyter notebook
This should spawn a browser with the available notebooks. Should your notebooks fail to execute, run
conda install jupyter
from the activated CNTK environmentcntk-py34
.
Step 5 (Optional): Verify the setup (BrainScript)
Perform the following command in the CNTK Python environment command prompt (see previous step):
cd c:\repos\CNTK\Examples\Other\Simple2d\Data
- Testing with CPU: Run the following command
cntk configFile=../Config/Simple.cntk makeMode=false 1> out.txt 2>&1
Look for the string Builder Using
in the resulting file out.txt
. You should be able to find this line:
SimpleNetworkBuilder Using CPU
- Testing with GPU: Run the following command
cntk configFile=../Config/Simple.cntk deviceId=auto makeMode=false 1> out.txt 2>&1
Look for the string Builder Using
in the resulting file out.txt
. You should be able to find a line like this:
SimpleNetworkBuilder Using GPU 0
Please follow the steps below to install the binaries. The installation script will additionally download the necessary dependencies and clone the CNTK repository, so an Internet connection is required when running the script.
The script was tested on Ubuntu 14.04 and 16.04 only. It will generate a warning about possible failures if run on any other platform.
Step 1: Download the appropriate binary package from CNTK Releases page. Unpack the tar.
Note: Choose a GPU binary download only if your machine has an NVidia GPU.
Step 2: Run bash Installation script
Below we assume that you have unpacked the CNTK Binary package to /home/username
.
- Run:
cd /home/username/cntk/Scripts/linux
./install-cntk.sh
The script will download some installation packages from remote locations. Expect that running it will take some time (expect at least 20 minutes on Ubuntu 16.04 and even more on Ubuntu 14.04 if none of the required pre-requisites are detected on your system).
By the end of the successful setup the script will inform you about the location of the CNTK Python environment script and of the location of CNTK BrainScript Examples and CNTK Python examples.
- For GPU Systems: Please ensure that you have the latest NVIDIA driver
Step 3: Verify the setup (Python)
- Activate CNTK environment by executing the command specified by the Installation script (see previous step). In our example it will be:
source "/home/username/cntk/activate-cntk"
-
Run the examples from inside the
[CNTK clone root]/bindings/python/examples
directory, to verify your installation. Runpython NumpyInterop/FeedForwardNet.py
. You should see the following output on the console:
Minibatch: 0, Train Loss: 0.7915553283691407, Train Evaluation Criterion: 0.48
Minibatch: 20, Train Loss: 0.6266774368286133, Train Evaluation Criterion: 0.48
Minibatch: 40, Train Loss: 1.0378565979003906, Train Evaluation Criterion: 0.64
Minibatch: 60, Train Loss: 0.6558118438720704, Train Evaluation Criterion: 0.56
- Run the tutorials by executing the following commands:
cd /home/username/repos/CNTK/bindings/python/tutorials
jupyter notebook
This should spawn a browser with all available notebooks ready to be run. Should the notebooks fail to execute, additionally run
conda install jupyter
from the activated CNTK environmentcntk-py34
.
Step 4 (Optional): Verify the setup (BrainScript)
Perform the following command in the CNTK Python environment (see previous step):
cd /home/username/cntk/Examples/Other/Simple2d/Data/
- Testing with CPU: Run the following commands
cntk configFile=../Config/Simple.cntk makeMode=false &> out
cat out | grep Builder
You should get the following output:
SimpleNetworkBuilder = [
SimpleNetworkBuilder Using CPU
- Testing with GPU: Run the following command
cntk configFile=../Config/Simple.cntk deviceId=auto makeMode=false &> out
cat out | grep Builder
Look for the string Builder Using
in the resulting file out.txt
. You should get an output like this:
SimpleNetworkBuilder = [
SimpleNetworkBuilder Using GPU 0