Build DLDT App Inside Windows* Docker Container

Published: 09/06/2019  

Last Updated: 09/06/2019

Learn how to automate the build process of a DLDT app inside a Windows* Docker Container.

Step 1: Download Intel® System Studio Package

  1. Go to the Downloads page.
  2. Click Configure Installation.
  3. Select 2 packages:
    1. Intel® Threading Building Blocks
    2. Intel® C++ Compiler
  4. Optional: in the top right corner, it says the package Includes Eclipse IDE (400 MB)*. You may click remove because we do not need Eclipse.
  5. In the top right corner, click Continue to Download. You may click the gray text on the bottom: "Maybe next time..."
  6. You will see four download options. Click Download for the one that says Windows* Host, Windows* Target, (Plugin for Visual Studio)
  7. Unzip the folder, named intel-sw-tools-installation-bundle-win-win.
  8. Place this folder in the same directory as your Dockerfile.

Step 2: Build and Run the Docker Image

Configure Dockerfile

Before you run docker build, please read the Dockerfile Walkthrough section down below for the Dockerfile code and make any necessary edits.

Docker build

Go to the directory containing your Dockerfile and build the image.

  • The -m flag is used to allocate extra memory to the build. (Installing Visual Studio and building DLDT properly requires this.)

Note Building DLDT has been found to use roughly 3GB of RAM at its peak.

  • Make sure you have hard drive space available, as the resulting image will take 30GB of disk space.

cd <directory with Dockerfile in it> 
docker build -m 4GB -t security-app .

Note Pulling the Windows* amd-64 image may take a long time, and at times you may see full progress bars (during "Extracting" phase) hang for over 20 minutes. Check your task manager, and if Docker is still running, it means that the build is probably working, even if it may not seem so.

Note The entire build process will take 3-4 hours.

Docker run

Use the command below to run the camera demo in the Docker container.

  • [$path] should be the absolute path to the folder containing the images / videos you want to run the app on.
  • The -no_show and -r flags are used to make sure that the application output is printed as text (as we cannot view image or video output from the Docker container)
docker run -v [$path]:C:\media security-app security_barrier_camera_demo -i C:\media\car_1.bmp -d CPU -d_va CPU -d_lpr CPU -m C:/demo/models/vehicle-license-plate-detection-barrier-0106.xml -m_va C:/demo/models/vehicle-attributes-recognition-barrier-0039.xml -m_lpr C:/demo/models/license-plate-recognition-barrier-0001.xml -no_show -r

Dockerfile Walkthrough

Here is an explanation of the steps of the Dockerfile.

Note The steps with a star next to them are especially important to read carefully because they may involve you editing the provided Dockerfile to make sure things run properly.

Step 1: Pull Image *

We pull the full Windows* Image to run our build. Windows* Nano Server and Server Core images have trouble installing Visual Studio and do not have the dependencies to run the security camera app.

Note Check your Windows* version! The provided Dockerfile uses the Windows* 10 1903 base image, but an older Windows* host cannot run a newer Windows* container. For example, if your Windows Version is Windows 10 1809, you will need to edit the base image to

Note The first line of the Dockerfile sets the line escape character to ` from the default \.

# escape=`
SHELL ["cmd", "/S", "/C"]

Step 2: Configure Proxies (Optional) *

If you are working behind a proxy, you will need to uncomment these lines configure their addresses here:

# RUN setx /M HTTP_PROXY <http proxy address> ;` # setx /M HTTPS_PROXY <https proxy address>

Step 3: Install Visual Studio Build Tools

We download the VS bootstrapper and use it to install build tools.

# Download the Build Tools bootstrapper. 
ADD C:\\TEMP\\vs_buildtools.exe 

# Run the Build 
RUN C:\temp\vs_buildtools.exe ` 
    --quiet --wait --norestart --nocache ` 
    --add Microsoft.VisualStudio.Component.VC.CoreBuildTools ` 
    --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ` 
    --add Microsoft.VisualStudio.Component.Windows10SDK.17134 ` 
    || IF "%ERRORLEVEL%"=="3010" EXIT 0

Step 4: Install the Intel® C++ Compiler *

We copy our Intel® System Studio installation package into the container and run a silent installation.

Note Make sure that the intel-sw-tools-installation-bundle-win-win folder is in the same directory as your Dockerfile!

# Copy installation package into container 
COPY ["intel-sw-tools-installation-bundle-win-win", "C:/temp"] 

# Run the silent installer 
RUN start /wait ` 
    C:\temp\system_studio_2019.4.077_windows_target_web_configurator_online.exe ` 
        --silent -a install --output=C:\temp\logs.txt --eula=accept ` 
        --license=C:\temp\intel-sw-tools-license.lic --update=coexist ;` 
    rmdir /s /q C:\TEMP

Step 5: Install Chocolatey and Dependencies

We install Chocolatey using PowerShell and use it to install other dependencies, such as CMake, Git, Wget, and Python.

Note I specified version numbers for CMake, Git, and Python for consistency. Only the latest version of Wget is able to download files specified by CMake properly later.

# Install Chocolatey 
RUN powershell Set-ExecutionPolicy Bypass 
RUN powershell -Command ` 
        iex((new-object net.webclient).DownloadString('')) 
RUN choco feature disable --name showDownloadProgress 

# Install Cmake, Git, Wget, and Python 
RUN choco install -y cmake --version 3.14.3 
RUN choco install -y git.install --version 2.22.0 
RUN choco install -y wget 
RUN choco install -y python3 --version 3.6.8

Step 6: Configure Stuff

We switch to PowerShell and add CMake to PATH, as this is not done by default.

# Switch to PowerShell 
SHELL ["powershell", "-NoLogo", "-ExecutionPolicy", "Bypass"] 

# Add CMake to PATH 
RUN $newpath = $env:path + "';C:\Program Files\Cmake\Bin;'" ;` 
    Set-ItemProperty -Path ` 
        'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session ` 
        Manager\Environment' -Name PATH -Value $newpath

Step 7: Build DLDT Inference Engine

We clone the DLDT repository and use it to build the Inference Engine.

Building VS Solution Files: We specify options to avoid building the DLDT plugins for GPU, VPU, etc. (we can't run them anyways) and the DLDT sample applications.

Build Inference Engine: For some reason, the final cmake --build command returns an error code 1 (even though everything is built properly), so we force an exit code of 0.

# Clone DLDT Inference Engine and submodules 
RUN cd C:\ ;` 
    git clone --depth=1 ;` 
    cd dldt\inference-engine ;` 
    git submodule init ;` 
    git submodule update --recursive 

# Building VS Solution Files 
RUN cd C:\dldt\inference-engine ;` 
    mkdir build ;` 
    cd build ;` 
    cmake .. -G "'Visual Studio 15 2017 Win64'" -T "'Intel C++ Compiler 19.0'" ` 
        -DICCLIB="'C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019\windows\compiler\lib'" ` 

# Build Inference Engine 
RUN cd C:\dldt\inference-engine\build ;` 
    cmake --build . --config Release ;` 
    EXIT 0

Step 8: Build Security Barrier Camera Demo

We clone the Open Model Zoo repository and call a pre-written script to build the Security Camera Demo app, along with other apps.

Note We must clone the 2019 branch from Open Model Zoo. The main branch does not support building the demos using the open-sourced DLDT Inference Engine binaries (it uses the Inference Engine from OpenVINO).

# Clone Open Model Zoo (OMZ)
RUN cd C:\ ;`
    git clone --single-branch --branch 2019 --depth 1 `

# Configure ENV and use env to build OMZ demos 
RUN $env:InferenceEngine_DIR = C:\dldt\inference-engine\build ;`
        # ^ Path to Inference Engine Cmake Files
    $env:OpenCV_DIR = C:\dldt\inference-engine\temp\opencv_4.1.0\cmake ;`
        # ^ Path to OpenCV Cmake Files
    cd C:\open_model_zoo\demos ;`

Step 9: Download Models

We install Python dependencies and download the models required to run our app.

# Download Python dependencies for OMZ model downloader
RUN pip install requests ;`
    pip install pyyaml

# Download Machine Learning Models
RUN cd C:\open_model_zoo\model_downloader ;`
    python .\ --name 'vehicle-license-plate-detection-barrier-0106,vehicle-attributes-recognition-barrier-0039,license-plate-recognition-barrier-0001'

Step 10: Aggregate Files

We edit PATH as necessary to allow the demo app to run and move the machine learning models to a more accessible location.

Note: You may need to change the openCV version!

# Add Dependencies to System PATH
RUN $newpath = $env:path + 'C:\dldt `
        \inference-engine\bin\intel64\Release;C:\dldt\inference-engine `
        \temp\opencv_4.1.0\bin;C:\dldt\inference-engine\temp\tbb\lib;' ;`
    Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System `
        \CurrentControlSet\Control\Session Manager\Environment' `
        -Name PATH -Value $newpath

# Move Camera Demo and OMZ Models to accessible location
RUN mkdir demo ;`
    mv C:\Users\ContainerAdministrator\Documents\Intel\OpenVINO\omz_demos_build`
        \intel64\Release\security_barrier_camera_demo.exe C:\demo ;`
    mkdir demo/models ;`
    mv C:\open_model_zoo\model_downloader\Security\object_attributes\vehicle`
        \resnet10_update_1\dldt\* C:\demo\models ;`
    mv open_model_zoo\model_downloader\Security\object_detection\barrier`
        \0106\dldt\* C:\demo\models ;`
    mv C:\open_model_zoo\model_downloader\Security\optical_character_recognition`
        \license_plate\dldt\* C:\demo\models

# Add Camera Demo to System PATH
RUN $newpath = $env:path + 'C:\demo;'  ;`
    Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet `
        \Control\Session Manager\Environment' -Name PATH -Value $newpath


Product and Performance Information


Performance varies by use, configuration and other factors. Learn more at