Wiki

Clone wiki

DeepDriving / InstallWindowsCompile

Installation on Windows

Compiling the C-Libraries

Introduction

For several reasons some python modules require C-Libraries, which must be compiled, before using the python modules. The following libraries are contained in this project:

  • leveldb: A version of the leveldb library, which uses CMake and can be compiled on Windows. This is simply a copy of the following project: leveldb-cmake. This library is required to read the original training data, which are provided as leveldb files.

  • datareader: A library which uses the leveldb library to read the original training data and decode it to raw data, which can be used by python.

  • situation: A library which creates an image of the nearby situation around the host car. This code is derived from the original DeepDriving project.

  • drivecontroller: A library which calculates the steering, acceleration and breaking commands for the game out of the 14 indicators from the neural network. This code is derived from the original DeepDriving project.

Pre-Requirements

The following software is needed to compile this project:

  • The following description is for Windows (10) and Microsoft Visual C++ 2015 (the free community edition is working perfectly). But it should also work with different Visual C++ versions and with MinGW.

    • Attention: If you use Visual Studio 2017, the default vcvarsall.bat amd64 script to enable the 64bit toolset does not work. Please use <visual-studio-install-dir>\VC\bin\amd64\vcvars64.bat instead to enable the toolchain for your command line (see: Stack Overflow).
  • For cloning the repository, GIT LFS is necessary. Otherwise the media files (music, sound, graphic) are missing.

  • You need MSYS2 installed on your computer. Also take care, that the path <msys-install-dir>\usr\bin is added to your PATH environment variable for the console you are using for compiling.

  • You need CMake (at least version 3.7).

  • You need Git as command line tools installed on your computer. For example by installing TortoiseGIT with command line support. It is important, that the command git is accessible from your command-line.

  • Boost 1.62: Can be downloaded as binary package from here.

    • You must download the 64bit version, which fits to your compiler version. If you use for example Visual Studio 2015 or 2017, the package boost_1_62_0-msvc-14.0-64.exe would be the right one.
    • In order to allow CMake to find the boost library, you need to add the path of the library files to your PATH environment variable. For example with: set PATH=%PATH%;C:\Boost\boost_1_62_0\lib64-msvc-14.0
  • OpenCV 3: Can be downloaded as binary package from here.

    • In order to allow CMake to find the OpenCV library, you need to add the path of the library files to your PATH environment variable. For example with: set PATH=%PATH%;C:\OpenCV\opencv\build\x64\vc14\bin
  • Snappy: Can be downloaded as binary package from here.

    • In order to allow CMake to find the Snappy library, you need to add the path of the library files to an environment variable called SNAPPY_ROOT. For example with: set SNAPPY_ROOT=C:\Snappy\snappy-windows-1.1.1.8

Prepare Compiling

  • Open a command prompt from which your compiler and all environment-variables from above are accessible. For example if you use Visual Studio 2015, you can open an ordinary terminal window (cmd.exe) and call the corresponding Batch-file from Visual Studio:
call "<Visual Studio 2015 installation path>\VC\vcvarsall.bat" amd64
  • Clone this repository. In all upcoming steps the path, where the repository was cloned to is called <repository-path>. Cloning the repository may take some times because some big files need to be downloaded (like the pre-trained tensorflow checkpoint).
git clone https://bitbucket.org/Netzeband/deepdriving.git

cd deepdriving

git checkout v1.0
  • Open the CMake GUI:
cmake-gui
  • Enter the library path <repository-path>/library in the file "Where is the source code".
  • Enter a build path in the field "Where to build the binaries". I prefer to always use the path <repository-path>/library/build/win64-msvc2015/debug.

Step 1

  • Press the button "Configure".

  • If it asks to create the build directory simply answer with "Yes".

Step 2

  • Select as generator the tool "NMake Makefiles" and select the option "Use default native compilers".

Step 3

  • During the first configuration, an error should come up, which complains that the OpenCV library could not be found.

  • To fix this error, add the path of the OpenCV library to the variable OpenCV_DIR. For example C:/OpenCV/opencv/build.

Step 4

  • Furthermore, set the build type to "debug", by settings the variable CMAKE_BUILD_TYPE to Debug.
  • Also set a proper installation directory to the variable CMAKE_INSTALL_PREFIX. I prefer to use the directory <repository-path>/library/install/win64-msvc2015/debug

Step 5

  • Press Configure again. All errors should be disappeared. The log-output should look like that:
OpenCV ARCH: x64
OpenCV RUNTIME: vc14
OpenCV STATIC: ON
Found OpenCV: C:/OpenCV/opencv/build (found version "3.2.0") 
Found OpenCV 3.2.0 in C:/OpenCV/opencv/build/x64/vc14/lib
You might need to add C:\OpenCV\opencv\build\x64\vc14\bin to your PATH to be able to run your applications.
Boost version: 1.62.0
Found the following Boost libraries:
  filesystem
  date_time
  system
Compile library dd-situation-view...
 * Use Defines: COMPILE_DLL
 * Use Include-Dirs: ../common/includes;includes;src/includes
Compile library dd-drivecontroller...
 * Use Defines: COMPILE_DLL
 * Use Include-Dirs: ../common/includes;includes;src/includes
Looking for pthread.h
Looking for pthread.h - not found
Found Threads: TRUE  
Boost version: 1.62.0
Found the following Boost libraries:
  date_time
  filesystem
  system
  thread
  chrono
  atomic
Read snappy root-directory from environment variable SNAPPY_ROOT: C:\Snappy\snappy-windows-1.1.1.8
Found Snappy:
 * Snappy include path: C:/Snappy/snappy-windows-1.1.1.8/include
 * Snappy library:      C:/Snappy/snappy-windows-1.1.1.8/native/snappy64.lib
 * Snappy DLL:      C:/Snappy/snappy-windows-1.1.1.8/native/snappy64.dll
Enable Win32 port...
Compile library dd-datareader...
 * Use Defines: COMPILE_DLL
 * Use Include-Dirs: ../common/includes;includes;src/includes
Configuring done
  • Press "Generate" and close the cmake-gui.

Compiling

  • Change to the build directory:
cd <repository-path>\library\build\win64-msvc2015\debug
  • Start build process:
nmake
  • After build, install everything:
nmake install

Computer-Setup

  • You need to add the path <install-path>\python to the PYTHONPATH environment variable of your session/computer. Otherwise the deep-driving script cannot find the python modules for those libraries.

  • Example:

set PYTHONPATH=%PYTHONPATH%;<repository-path>\library\install\win64-msvc2015\debug\python

Testing

  • Change to the python folder of the install-directory:
cd <repository-path>\library\install\win64-msvc2015\debug\python
  • Here you can run several example python scripts.

  • The script example_datareader.py opens a training data leveldb directory from the original DeepDriving project and shows the images on a small window. By pressing any key the next image is shown. By pressing escape, the example application exits:

python example_datareader.py <original-deepdriving-training-data>
  • The script example_drivecontroller.py tests the drive-controller:
python example_drivecontroller.py
  • The script example_situation_view.py tests the situation view generator. By pressing escape the next mode is shown or the application exists.
python example_situation_view.py

Next Step

Updated