-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Setup Migrate VS13 to VS15
If you already build CNTK from source code on Windows using Visual Studio 2013 and want to move to a Visual Studio 2015 based developement environment, this page is for you.
If you are looking for any other kind of support in setting up a CNTK build environment or installing CNTK on your system, you should go here instead.
Next to the obvious switch to a new developement environment, the new development environment comes with a different set of run-time libraries and dependencies. The following pages will guide you through the required changes and installation steps.
The required changes performed here are additive, that means that we will install versions of libraries and tools specific to building CNTK with Visual Studio 2015. Next to installation of these tools, we need to adjust the system environment variables to refer to the new location.
For an overview of the environment variables used by the Windows build of CNTK please see this page.
Below is the list of environment variables and the destination location for these files. This is not a requirement and you can choos your own destinations, but using these locations you are mirroring the setup of our internal build and test system, and so eliminating possible problems. Please also note that we added runtime or compiler information to the name of some directories, this allows us to have different versions of tools installed side-by-side on the system. We also try to keep all the installed tools in the c:\local
directory, that way localizing CNTK specific tools.
setx BOOST_INCLUDE_PATH c:\local\boost_1_60_0-msvc-14.0
setx BOOST_LIB_PATH c:\local\boost_1_60_0-msvc-14.0\lib64-msvc-14.0
setx CNTK_MKL_PATH c:\local\CNTKCustomMKL
setx CUB_PATH c:\local\cub-1.4.1
setx CUDNN_PATH C:\local\cudnn-8.0-v5.1\cuda
setx OPENCV_PATH_V31 c:\local\Opencv3.1.0\build
setx PROTOBUF_PATH c:\local\protobuf-3.1.0-vs15
setx SWIG_PATH c:\local\swigwin-3.0.10
setx ZLIB_PATH c:\local\zlib-vs15
Required
Install Microsoft Visual Studio 2015.3 for Windows. A link to the download can be found here. Please install Visual Studio 2015, not a previous version or the 2017-Preview! The Community Version of Visual Studion 2015 is sufficient to build CNTK.
During the installation process please select custom installation:
On the feature selection screen make sure you add 'Common Tools for Visual C++ 2015' to your installation:
If you already have VS 2015 installed, make sure you are on Update 3. See the Help->About
menu to display the version number like "Version 14.0.25431.01 Update 3".
You are also required to have the 'Common Tools for Visual C++ 2015' installed on your system. To check open the Windows "Control Panel -> Programs -> Programs and Features' and select 'Microsoft Visual Studio Enterprise 2015 with Updates' from the list of installed programs. This will start the Visual Studio setup again and allows you to make sure the 'Common Tools for Visual C++ 2015' feature is installed on your system (see picture above).
Required
The version of our custom MKL library for CNTK changed for Visual Studion 2015. We recommend you install the custom CNTK-MKL into c:\local\CNTKCustomMKL
Installing the CNTK custom MKL library:
- Create a directory on your machine to hold CNTK custom MKL versions, e.g.:
mkdir c:\local\CNTKCustomMKL
- Set the environment variable
CNTK_MKL_PATH
to point to this directory:
setx CNTK_MKL_PATH c:\local\CNTKCustomMKL
- Download the file CNTKCustomMKL-Windows-3.zip. Unzip it into your CNTK MKL path, creating a numbered sub directory within. For example, if you are on latest master, download and extract its contents to
c:\local\CNTKCustomMKL\3
(the top-level folder inside the ZIP archive is called3
). For more information, see the CNTK web site.
Required
Boost is now a requirement to build CNTK. In addition you will need to update to a Boost version supporting Visual Studio 2015. We recommend you install the new Boost version into c:\local\boost_1_60_0-msvc-14.0
- Download and install Boost version 1.60 (you need the
msvc-14.0
binaries) from this download location on Sourceforge. - Set the environment variable
BOOST_INCLUDE PATH
to your Boost installation, e.g.:
setx BOOST_INCLUDE_PATH c:\local\boost_1_60_0-msvc-14.0
- Set the environment variable
BOOST_LIB_PATH
to the Boost libraries, e.g.:
setx BOOST_LIB_PATH c:\local\boost_1_60_0-msvc-14.0\lib64-msvc-14.0
- To integrate the Boost test framework into Visual Studio you can install a runner for Boost tests in Visual Studio from the Visual Studio Gallery.
Required
You need a version of Protobuf 3.1.0 compiled for CNTK. You can compile this version by yourself, or use an already (precompiled) prepared version of Protobuf 3.1.0.
Download the ZIP file containing the precompiled version of Protobuf from this location
- Extract the archive to a folder on your local disk, e.g. to
C:\local\protobuf-3.1.0-vs15
and set the environment variablePROTOBUF_PATH
pointing to that location, e.g.:
setx PROTOBUF_PATH c:\local\protobuf-3.1.0-vs15
- Quick installation check: If you followed the instruction above and used the same paths, the command
dir C:\local\protobuf-3.1.0-vs15\bin
will succeed.
If you want to build the Protobuf 3.1.0 for CNTK yourself, follow these instructions. The compiled Protobuf version will be located in c:\local\protobuf-3.1.0-vs15
- Install CMake from cmake.org.
- Download and unpack the protobuf sources from https://github.com/google/protobuf/archive/v3.1.0.zip.
The following steps assume that the Protobuf sources have been unzipped to the directory c:\local\src\protobuf-3.1.0
. The instructions below will create the Protobuf libraries and header files in the directory c:\local\protobuf-3.1.0-vs15
. If this location differs in your case, please adapt the steps below to match your directory structure.
- Launch a 64-bit Visual Studio 2015 development environment. The most convenient was is to execute the batch file
vcvarsall.bat
in the Visual Studio directory with the required parameters from a standard windows command shell:
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
If you can't find this batch file on your system, please revisit the installation of VS2015 and make sure you have the 'Common Tools for Visual C++ 2015' option selected. 2. Create a build directory:
c:\users\users> cd C:\local\src\protobuf-3.1.0\cmake
C:\local\src\protobuf-3.1.0\cmake> mkdir build && cd build
- Create a debug build:
C:\local\src\protobuf-3.1.0\cmake\build>mkdir debug && cd debug
C:\local\src\protobuf-3.1.0\cmake\build\debug>cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -DCMAKE_INSTALL_PREFIX="c:\local\protobuf-3.1.0-vs15" ..\..
C:\local\src\protobuf-3.1.0\cmake\build\debug>nmake && nmake install
C:\local\src\protobuf-3.1.0\cmake\build\debug>cd ..
- Create a release build:
C:\local\src\protobuf-3.1.0\cmake\build>mkdir release && cd release
C:\local\src\protobuf-3.1.0\cmake\build\release>cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -DCMAKE_INSTALL_PREFIX="c:\local\protobuf-3.1.0-vs15" ..\..
C:\local\src\protobuf-3.1.0\cmake\build\release>nmake && nmake install
C:\local\src\protobuf-3.1.0\cmake\build\debug>cd ..
- Set the environment variable
PROTOBUF_PATH
to the Protobuf location (Note: this is the install location used in the cmake command above, not the sources location!):
setx PROTOBUF_PATH c:\local\protobuf-3.1.0-vs15
The directory c:\local\-3.1.0-vs15
now contains all the Protobuf files needed for building the Microsoft Cognitive Toolkit. You may go ahead and delete the Protobuf source directory (C:\local\src\protobuf-3.1.0
).
Required if your are building a GPU enabled version of CNTK
Important Even if you already had NVIDIA CUDA 8 installed before the installation of Visual Studio 2015, you will need to run the NVIDIA CUDA 8 installation process again. The NVIDIA CUDA 8 installation adds support to the NVIDIA development tools to the Visual Studio environment, which is required to build CNTK successfully.
The latest version of NVIDIA CUDA 8 can be found at this download page
Just run the installation procedure to update your installation.
Required if you are currently building CNTK with zlib and libzip support
If you are building CNTK with ZLib and LibZip, you will need to recompile these package. The newly created binaries and include files will be in the location c:\local\zlib-vs15
.
We use the following installation paths in our instructions:
- zlib sources:
c:\local\src\zlib\zlib-1.2.8
- libzip sources:
c:\local\src\libzip-1.1.3
- Build directory for zlib and libzip binaries:
c:\local\zlib-vs15
You can use any paths you like, but note the remark on target folder for binaries below.
- Install CMake. Include CMake binaries folder to your
PATH
- Download zlib source code and unpack it to
c:\local\src\zlib\zlib-1.2.8
- Download libzip source code and unpack to
c:\local\src\libzip-1.1.3
IMPORTANT! The following aspects are important:
- Build commands for zlib and libzip should use the same target folder for binaries (specified via
-DCMAKE_INSTALL_PREFIX
parameter incmake
command below) - Build order is important. You should build zlib first because libzip is dependent on it
Launch a 64-bit Visual Studio 2015 development environment. The most convenient way is to execute the batch file vcvarsall.bat
in the Visual Studio directory with the required paramaters from a standard windows command shell:
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
If you can't find this batchfile on your system, please revisit the installation of VS2015, and make sure you have the 'Common Tools for Visual C++ 2015' option selected.
Execute the following commands from VS2015 x64 Native Tools Command Prompt:
cd c:\local\src\zlib\zlib-1.2.8
mkdir build
cd build
cmake .. -G"Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX="c:\local\zlib-vs15"
msbuild /P:Configuration=Release INSTALL.vcxproj
Execute the following commands from VS2015 x64 Native Tools Command Prompt:
cd c:\local\src\libzip-1.1.3
mkdir build
cd build
cmake .. -G"Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX="c:\local\zlib-vs15"
msbuild libzip.sln /t:zip /P:Configuration=Release
cmake -DBUILD_TYPE=Release -P cmake_install.cmake
MSBuild command above may generate some warnings. It is expected and may be ignored.
The last cmake
command from the list above will generate the following error:
CMake Error at src/cmake_install.cmake:34 (file):
file INSTALL cannot find "C:/libzip/build/src/Release/zipcmp.exe".
It is expected and may be ignored - all required binaries (zip.dll
and zlib.dll
) should be already in c:\local\zlib-vs15
- Set the following environment variable:
setx ZLIB_PATH c:\local\zlib-vs15
At this point you have finised the conversion of the CNTK build system to Visual Studio 2015. Make sure you have all the environmnent variables changed to the correct location. Start Visual Studio 2015 and perform a rebuild of the CNTK solution.