-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Recommended CNTK 2.0 Setup
You can install CNTK with in three different ways on Windows and Linux :
-
Binary install with prepackaged scripts (Recommended): This provides the fastest way to get started with CNTK and applicable to most practitioners. See the steps below.
-
Binary install with manual steps (Not Recommended): Only for those who need highly customized installations.
-
Build from sources (for developers): Those interested in contributing to CNTK.
[Note: The CNTK new Python and C++ APIs are an alpha release for early users to try and provide feedback on the usability and functional aspects of the API. Use of CNTK as an exe with BrainScript is not alpha, and 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 enables 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 natively on Windows with Python 3.4.4 and on Linux with Python 3.5. For both the 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 $HOME/anaconda3/envs/cntk-py34
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 Internet connection is required when running the script.
Step 1: Download the appropriate binary package from UPDATE PATH CNTK Releases page. Unpack the zip file into a local folder (say c:\local\
).
Step 2: Prepare to run PowerShell scripts:
- Open PowerShell with administrator priviledges
- 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 2: Run 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 per-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.
Step 3: Verify the setup (Python)
Open command prompt and activate 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
Run the following commands:
cd c:\repos\CNTK\bindings\python
python examples/NumpyInterop/feedforwardNet.py
If everything works correct you should get a console output like the one below:
Minibatch: 0, Train Loss: 0.6915470886230469, Train Evaluation Criterion: 0.52
Minibatch: 60, Train Loss: 0.6610990142822266, Train Evaluation Criterion: 0.56
Minibatch: 120, Train Loss: 0.31225751876831054, Train Evaluation Criterion: 0.2
Minibatch: 180, Train Loss: 0.1848754119873047, Train Evaluation Criterion: 0.08
Minibatch: 240, Train Loss: 0.19827106475830078, Train Evaluation Criterion: 0.08
Minibatch: 300, Train Loss: 0.16531991958618164, Train Evaluation Criterion: 0.04
Minibatch: 360, Train Loss: 0.8258456420898438, Train Evaluation Criterion: 0.28
Minibatch: 420, Train Loss: 0.31327741622924804, Train Evaluation Criterion: 0.16
Minibatch: 480, Train Loss: 0.14627487182617188, Train Evaluation Criterion: 0.04
Minibatch: 540, Train Loss: 0.19005121231079103, Train Evaluation Criterion: 0.12
Minibatch: 600, Train Loss: 0.15139059066772462, Train Evaluation Criterion: 0.04
Minibatch: 660, Train Loss: 0.10627300262451173, Train Evaluation Criterion: 0.04
Minibatch: 720, Train Loss: 0.33113689422607423, Train Evaluation Criterion: 0.12
Minibatch: 780, Train Loss: 0.3315776443481445, Train Evaluation Criterion: 0.12
Error: 0.120000
Step 4 (Optional): Verify the setup (BarinScript)
Perform the following command in the CNTK Python environment command prompt (see previous step):
cd C:\repos\CNTK\Examples\Other\Simple2d\Data
Before each new run of the tests below you need to delete the trained model by executing:
del ..\Output\Models\*.*
- Testing with CPU
Ensure ..\Output\Models
directory is empty or does not exist.
Run the following command
cntk configFile=../Config/Simple.cntk 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
Ensure ..\Output\Models
directory is empty or does not exist.
Run the following command
cntk configFile=../Config/Simple.cntk deviceId=auto 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 script will additionally clone the CNTK repository into /home/[USERNAME]/repos/cntk
. Note: we have tested the script on Ubuntu 16.0.4. We first summarize what the script installs for you and sets the environment variables.
Step 1: Prepare to run scripts:
- Step 1: Download the appropriate binary package from CNTK Releases page. Unpack the Tar.gz archive and change directory to the unpacked content.
Step 2: Run the bash scripts:
Run: bash Scripts/linux/install-cntk.sh
Step 3: Python updates
-
RUN:
source activate-cntk
to activate the CNTK environment. -
TODO If you want to deploy a new CNTK wheel package at a later time simply re-run:
pip install –upgrade [Whl file location]
Step 4: Verify setup
-
Python
- Change to where the examples are located and run the python script:
cd c:\repos\CNTK\bindings\python\examples\NumpyInterop
python FeedForwardNet.py
A successful implementation should run the python example and you should be able to see output in 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
-
Brainscript (optional)
- Please run the following self contained example:
cd C:\repos\CNTK\Examples\Other\Simple2d
CNTK configFile=Config/Simple.cntk currentDirectory=Data
You should be able to see the results getting printed on the console.