Skip to content

Python DyNet installation on Windows, with CUDA support

Victor Makarenkov edited this page Mar 1, 2017 · 3 revisions

This is a complementary DyNet installation instructions, that worked for me. It does not replace the official instructions at http://dynet.readthedocs.io/en/latest/python.html. Please read first http://dynet.readthedocs.io/en/latest/python.html, and then, only if needed, the following

The following was tested, and found working on Windows R2 Server, Standard edition, with NVIDIA GRID K2 GPU.

Python installed with Anaconda in C:\Anaconda2

Here I try to list the steps you need to follow in order to install DyNet on Windows with as least pain as possible.

  1. Verify Visual Studio 2015 in installed. If not, please install it. You can always download the community edition.

1.1) Verify you have the latest CUDA driver , version 8

  1. Download an Install CMake for windows. I tested it with 3.8.0 version.

  2. Download Boost, and extract to some folder the zipped file.

  3. Open the Visual Studio 2015 x64 Native Tools Command Prompt, and run it as Administrator.

  4. Compile Boost

4.1) cd to boost extracted folder and run: bootstrap.bat

4.2)after bootstrap.bat is complete, run (Will take at least 20 minutes): b2 toolset=msvc-14.0 --build-type=complete --abbreviate-paths architecture=x86 address-model=64 install -j4

4.3) set the following variables:

4.3.1)set BOOST_ROOT=c:\Boost

4.3.2)set BOOST_LIBRARYDIR=c:\Boost\lib

  1. Create a folder for the following downloads, for example: C:\dynet-base. Cd to this folder, with Visual Studio 2015 x64 Native Tools Command Prompt.

  2. Get Eigen: hg clone https://bitbucket.org/eigen/eigen/ -r 346ecdb

  3. Get DyNet: git clone https://github.com/clab/dynet.git

7.1) cd to dynet-base\dynet and create a folder called build: mkdir build, then cd to build

  1. Run cmake (Direction of slash matters!): cmake .. -DEIGEN3_INCLUDE_DIR=c:/dynet-base/eigen -DPYTHON=C:/Anaconda2/python.exe -DBACKEND=cuda -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0" -G"Visual Studio 14 2015 Win64"

This will create a dynet.sln solution

  1. Open Visual Studio (as administrator) and build the solution. The build at this point should succeed , except for the solution called target - that is it does not create a python library. (Otherwise you are done)

  2. go back to Studio 2015 x64 Native Tools Command Prompt:

10.1) python setup.py build --compiler=msvc

10.2) python setup.py install --user

Enjoy!