Xilinx DPU Setup Guide

The Xilinx setup tutorials demonstrate two paths to setting up the DPU. One route provides a pre-built PetaLinux system image with code examples, precompiled example binaries, and pre-trained models. The image can be flashed onto an SD card, and you should be able to boot the board directly from the SD card. Vivado and Vitis are not required. In fact, you can plug in a display and keyboard onto the ZCU104 board and use the board in standalone mode. It is also possible to SSH into the board over a network and interact with the board over SSH. More on that later. The other route, found here, shows how to start from a board design in Vivado and work your way up to Vitis and develop custom applications [1]. That is not a part of this guide; we will stick to the first option only for now.

Getting Started

You will want to download a copy of the PetaLinux DPU system image from the below link. Select the link matching your board model, in my case, ZCU104.

https://docs.xilinx.com/r/en-US/ug1414-vitis-ai/Flashing-the-OS-Image-to-the-SD-Card

You will also need BalenaEtcher to flash the system image to your SD card. So make sure you have that installed on your system. After you have both the system image and Etcher, follow the steps shown on the same page you downloaded the system image to create your bootable SD card. In most cases, you do not have to extract the image from the compressed archive; Etcher will take care of that. However, if Etcher fails to complete the process or verify the flashed image, you may have to extract the archive first using your favorite archive manager like WinRAR.

Booting PetaLinux

Assuming you are not planning on using the board in standalone mode, there are a few things you will need to get right for this next part.

  1. Ensure the Xilinx platform cable drivers are installed; otherwise, you will not see anything on the serial console. The cable drivers are installed along with Vivado when you run that installation.
  2. Have Putty, TeraTerm, or whatever is your favorite serial console application installed and ready.
  3. Configure the dip switches on the ZCU104 board to boot from the SD card.

On Windows, with the USB cable connected between your board and computer, you can look at the Device Manager to see which new COM/Serial device appears when you power on the board. Two new devices should show up, and you may have to try both when you open a serial connection. Use the following configuration to open a serial link:

Baudrate: 115200
Data bits: 8
Stop bits: 1
Parity: None

Check this configuration if you see garbage on screen (in TeraTerm or whatever) when you boot the board.

When you power on the board, you should see a light sequence that goes from red to green in the area near the SD card slot. If the light is not turning green, check either the dip switches and make sure they are set to boot from the SD card or something went wrong while flashing the SD card.

You should see PetaLinux booting in your console window if everything went as expected. At the end of the boot sequence, the boot process will appear to be stuck. Just press any key, and the program will continue and drop down to a shell.

First Step

When your board is booting, the first thing you want to do is get the board connected to the network. Connect an Ethernet cable to the board and plug the other end into a switch or router on the same network as your computer.

Once you’ve plugged the board onto the network, run ip -h -f inet address command to see the IP address assigned to eth0 link on the board. You will need it to SSH into the board.

Connecting Over SSH

ssh root@{ip_address}

When you’re ready to SSH into the board, I recommend using MobaXterm because MobaXterm gives you an all-in-one environment that can handle the file transfer, SSH, and, best of all, an X session. There are two pitfalls you want to watch out for:

  1. Using other terminal programs, SSH commands like scp for copying files between host and server will sometimes not work correctly. You know, you’ve run into this if you continuously get a ‘host not found error.’
  2. You need to establish an X session to view the output of the DPU in some cases. For example, when the output is an image or video, you will not be able to see what the DPU is doing without an X session. MobaXterm will automatically open an X window to display images. Enable the X-Session forwarding option in MobaXterm to get this working. If you see this error message, Gtk-WARNING **: 04:15:35.330: cannot open display:, make sure X-session forwarding is enabled and make sure you’re connected over SSH not UART.

Once you have established a connection, you can move on to the next section and copy model inputs onto the board.

Almost There

Now let’s copy the model inputs onto the board. This is the last step before we can actually run some examples. Back on the Xilinx page, under the ‘Running Vitis-AI Examples’ section, find a download link and download the examples archive. You can use wget to download the examples directly onto the board or use MobaXterm or FileZilla.

Extract the examples archive into the VART directory.

tar -xzvf vitis_ai_runtime_r2.0.0_image_video.tar.gz -C ~/Vitis-AI/demo/VART

Running Examples

Xilinx documentation on the DPU lists all the available examples and how to run them. Below you will find all the examples and how to run them. All the example directories also contain source code which may be useful in crafting similar applications targeting the DPU.

Resnet50

# root@xilinx-zcu104-2021_2:~#
cd /home/root/Vitis-AI/demo/VART/resnet50 ./resnet50 /usr/share/vitis_ai_library/models/resnet50/resnet50.xmodel

# Output

Resnet50 Output:

# root@xilinx-zcu104-2021_2:~#
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0330 04:15:34.966986  1071 main.cc:292] create running for subgraph: subgraph_conv1

Image : 001.jpg
top[0] prob = 0.982662  name = brain coral
top[1] prob = 0.008502  name = coral reef
top[2] prob = 0.006621  name = jackfruit, jak, jack
top[3] prob = 0.000543  name = puffer, pufferfish, blowfish, globefish
top[4] prob = 0.000330  name = eel

![[resnet50 output.png]]

Other Examples

Adas Detection

# root@xilinx-zcu104-2021_2:~#
cd /home/root/Vitis-AI/demo/VART/adas_detection
./adas_detection video/adas.webm /usr/share/vitis_ai_library/models/yolov3_adas_pruned_0_9/yolov3_adas_pruned_0_9.xmodel

Inception

# root@xilinx-zcu104-2021_2:~#
cd /home/root/Vitis-AI/demo/VART/inception_v1_mt_py
python3 inception_v1.py 1 /usr/share/vitis_ai_library/models/inception_v1_tf/inception_v1_tf.xmodel

Pose Detection

# root@xilinx-zcu104-2021_2:~#
cd /home/root/Vitis-AI/demo/VART/pose_detection
./pose_detection video/pose.webm /usr/share/vitis_ai_library/models/sp_net/sp_net.xmodel /usr/share/vitis_ai_library/models/ssd_pedestrian_pruned_0_97/ssd_pedestrian_pruned_0_97.xmodel

Resnet50_mt_py

# root@xilinx-zcu104-2021_2:~#
cd /home/root/Vitis-AI/demo/VART/resnet50_mt_py
python3 resnet50.py 1 /usr/share/vitis_ai_library/models/resnet50/resnet50.xmodel

Segmentation

# root@xilinx-zcu104-2021_2:~#
cd /home/root/Vitis-AI/demo/VART/segmentation
./segmentation video/traffic.webm /usr/share/vitis_ai_library/models/fpn/fpn.xmodel

Squeezenet_pytorch

# root@xilinx-zcu104-2021_2:~#
cd /home/root/Vitis-AI/demo/VART/squeezenet_pytorch
./squeezenet_pytorch /usr/share/vitis_ai_library/models/squeezenet_pt/squeezenet_pt.xmodel

Video Analysis

# root@xilinx-zcu104-2021_2:~#
cd /home/root/Vitis-AI/demo/VART/video_analysis
./video_analysis video/structure.webm /usr/share/vitis_ai_library/models/ssd_traffic_pruned_0_9/ssd_traffic_pruned_0_9.xmodel

References

[1]. Xilinx Design User Guide, PG338 DPU