Testing the SeeChange engine build environment on your local development machine

SeeChange Asset Builder

Testing the SeeChange engine build environment by building the example asset code for a Jetson AGX/NX on your local development machine

First, choose your build platform – Windows10, Windows10 WSL2, Ubuntu linux (other distributions also supported) or Mac OS v10.15 or better.

See the URLS contained within the highlighted links at the end of this document.

Read more about running arm64(aarch64) containers on x86 and install the following

For Windows 10 or Mac OS

Install Docker Desktop for your platform

Open Docker Desktop Preferences -> Resources -> ADVANCED and increase the memory and CPU allocation
For example on my 2019 MacBook Pro that has a quad-core i7 and 16GB RAM, the default is
4 CPUs (out of 8) and 2GB RAM (out of 16)
I chose to leave CPUs at 4 and increased RAM to 8GB

Read about running different hardware architecture in Docker Desktop multi-arch support

For WSL2 or linux

If you want to run on ubuntu linux or WSL2, I would recommend these links to install docker and docker-compose:

Read more about running arm64(aarch64) containers on x86

Then install the qemu packages

sudo apt-get install qemu binfmt-support qemu-user-static

The following step will execute the registering scripts to enable docker multi-arch support

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

Test the emulation environment

docker run --rm -t arm64v8/ubuntu uname -m

Should respond with ‘aarch64’

Pull the relevant build environment from Docker Hub

If you haven’t already, create yourself an account on Docker Hub and login

Search for ‘insightarm/cpp’

There are several build environment docker images available and they are labelled using with a specific convention, for example

– 4-0-0 is the build revision for the engine

– p2888 is the Nvidia internal code for the Jetson AGX and NX platforms

– The 3rd parameter of the tag indicates the jetpack SDK version – 4.2.24.34.4

 Note that the build revision should match the revision of the engine source provided separately by Seechange as a tarball

Click on Tags and filter for ‘4-0-0-p2888’ to find images that are relevant for the AGX, build revision 4.0.0

Docker Image Set-up (Local Development Environment)

There are lots of clever ways to build a personalised docker environment, but it is possible to load the image and run a bash shell with

docker run -it --platform linux/aarch64 --name engine_builder insightarm/cpp:4-0-0-p2888-4.3 /bin/bash

This will take some time as it pulls and extracts around 17GB of image and should finally deliver a shell prompt

Just FYI, in Docker Hub click on the highlighted name directly under the word TAG to see the build script for the image

Exiting the shell will stop the docker container, to restart with a shell prompt – without pulling the image again, just run

docker images

To see a list of the images available. Copy the IMAGE ID for build environment into

docker run -it --platform linux/aarch64 <IMAGE ID> /bin/bash

The result is a running aarch64 (arm64) build environment on your x86-based development machine. 

Running with docker-compose

 A simple docker-compose.yml file

version: "3.8"
services:
dev:
   image: insightarm/cpp:4-0-0-p2888-4.3
   container_name: engine_builder
   network_mode: bridge
   restart: unless-stopped
   volumes:
      - .:/tmp

Can be run using the following command line

docker-compose run dev bash

Building the asset

The engine sourcecode tarball provided by Seechange is a stripped-down version of our engine source code so that you can build your C++ or Python model or library into an asset that can be loaded to a Jetson Nvidia device via our SeeWare adminUI.

Docker allows the assignment of a folder (volume) in your local development environment into a Docker container

Create a local source folder (~/src) and expand into it the engine sourcecode tarball

The Docker command line option ‘-v local:container’ provides a symbolic link between your local folder and an accessible folder within the build environment container (/tmp)

So, to include a local build environment into the Docker container

docker run -it -v /home/$USER/src:/tmp --platform linux/aarch64 <IMAGE ID> /bin/bash

This will open the Docker container at a bash shell prompt and if you look in the ‘/tmp’ directory you will see the engine framework

The next step is to run through a cmake, make, make test, make install process to build the example inferrer in the Docker container

cd /tmp/SeeChange-Engine-4.0.0/engine/engine_bindings/
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/../ ../src
make -j$(nproc –-ignore=2)
make test
make install

The example from cpp/src/engine/example has been built and is available here

build/engine/example/libengine_example.so 

Packaging the asset

A tarball containing this file and a descriptive json file should be bundled together. This can then be imported as an asset via the adminUI

The json file has the following structure

{
"module_name": "engine.inference.CppInferrer",
"class_name": "CppInferrer",
"cpp": {
"library_name": "libengine_example.so",
   "function_name": "CreateInferrer"
},
"model_name": "demo_cpp_v1"
}

Note the “model_name” and the name of the json file should match the name of the tarball

It is possible to manually create the tarball like so

tar czf demo_cpp_v1.tar.gz demo_cpp_v1.json libengine_example.so

A more flexible method to create the tarball is provided by a Python script – asset_maker.py Here is an example, starting from the build folder

cd ../..
export PYTHONPATH=$PWD:$PYTHONPATH
./engine_bindings/asset_maker.py --asset cpp_example_simple_inferrer.tar.gz --metadata '{"cpp":{"libraryName":"libengine.example.so","functionName":"CreateExampleSimpleInferrer"}}' --file engine_bindings/libengine_example.so

The result is a loadable asset that can be added for deployment via a solution in the SeeWare admin UI. It will simply draw random bounding boxes with a single pixel red line on any stream associated with the AGX as processor.

Links mentioned in the above document

Running arm64(aarch64) containers on x86

https://www.stereolabs.com/docs/docker/building-arm-container-on-x86/

Docker Desktop

https://www.docker.com/products/docker-desktop

Docker Desktop multi-arch support

https://docs.docker.com/desktop/multi-arch/

Install Docker

https://docs.docker.com/engine/install/ubuntu/#install-using-the-convenience-script

Docker-compose

https://docs.docker.com/compose/install/

Running arm64(aarch64) containers on x86

https://www.stereolabs.com/docs/docker/building-arm-container-on-x86/

Docker Hub

https://hub.docker.com/