Part 1 (Virtual Environment)

This section of the tutorial will walk you through creating the necessary virtual environment for you to build a Pytorch stage that does basic image detection using resnet50.

It’s a good idea to complete the standard introductory tutorial before moving on to this tutorial.

There are a few assumptions:

  • Ark is installed in ${APP_ROOT}/ark
  • You have successfully built Ark (and all required dependencies are installed)

Creating the Environment

First, let’s make a tutorial directory to do our work in.

cd ${APP_ROOT}/ark
mkdir -p tutorial

Add this to the top-level ${APP_ROOT}/CMakeLists.txt file:


Next, let’s build out the CMakeLists.txt file:

    torch torchvision opencv-python

There’s a few things going on here. First, we’ll create a virtualenv known as tutorial_venv. This will be placed in your build/ark_python_venvs/tutorial_venv directory.

It will install the torch, torchvision, and opencv-python modules via pip into the venv. It will then copy the pyserialize and pypipeline Ark python libraries into that venv, and finally, generate rbuf parsers for the control messages and image message targets.

Next, in Step 2, we’ll work on initializing Pytorch itself.