For Data Center (Versal V70 Card) - For Data Center (Versal V70 Card) - 3.5 English - UG1354

Vitis AI Library User Guide (UG1354)

Document_ID
UG1354
Release_Date
2023-06-29
Version
3.5 English
Set up the host by running the Docker image.
  1. Clone the Vitis AI repository.
    $ git clone https://github.com/Xilinx/Vitis-AI
    $ cd Vitis-AI
  2. Run the Docker container according to the instructions in the Docker installation guide.
    $ ./docker_run.sh -X xilinx/vitis-ai-<pytorch|tensorflow2|tensorflow>-cpu:latest
    Note: A workspace folder is created by the Docker runtime system and is mounted in the /workspace folder of the Docker runtime system.
  3. Place the program, data, and other files to be developed in the workspace folder. After the Docker system starts, locate them in the /workspace folder of the Docker system.
    Warning: Do not put the files in any other path of the Docker system. They will be erased after you exit the Docker system.
  4. Select the model for your platform. You can find the download links for the latest models in the yaml files of the model in the Vitis-AI/model_zoo/model-list location.
    • If the /usr/share/vitis_ai_library/model folder does not exist, create it first.
      $ sudo mkdir -p /usr/share/vitis_ai_library/models
    • For the Versal V70 Prod card, take resnet_v1_50_tf as an example.
      $ wget https://www.xilinx.com/bin/public/openDownload?filename=resnet_v1_50_tf-v70-DPUCV2DX8G-r3.5.0.tar.gz -O resnet_v1_50_tf-v70-DPUCV2DX8G-r3.5.0.tar.gz
      $ tar -xzvf resnet_v1_50_tf-v70-DPUCV2DX8G-r3.5.0.tar.gz
      $ sudo cp resnet_v1_50_tf /usr/share/vitis_ai_library/models -r
  5. Download the xclbin package from here. Untar it, select the Versal card DPU IP and install it.
    $ sudo tar -xzvf DPUCV2DX8G_xclbins_3_5_0.tar.gz -C /
    $ export XLNX_VART_FIRMWARE=/opt/xilinx/overlaybins/DPUCV2DX8G/V70/dpu_DPUCV2DX8G_250M_xilinx_v70_gen5x8_qdma_base_2.xclbin
  6. If there is more than one card installed on the server and you want to which cards will be used for inference, you can set XLNX_ENABLE_DEVICES to achieve this function. The following is the usage of XLNX_ENABLE_DEVICES:
    • export XLNX_ENABLE_DEVICES=0: Only use device 0 for DPU.
    • export XLNX_ENABLE_DEVICES=0,1,2: Use device 0, device 1, and device 2 for DPU.
    • If you do not set this environment variable, all devices are used for DPU (default).
  7. To compile the library sample in the Vitis AI Library , take classification for example, execute the following command:
    $ cd /workspace/examples/vai_library/samples/classification
    $ bash -x build.sh

    The executable program is now produced.

  8. To modify and compile the library source under /workspace/src/vai_library.

    Before compiling the Vitis AI Library, confirm the compiled output path. The default output path is $HOME/build.

    If you want to change the default output path, modify the build_dir_default in cmake.sh. For example, change from build_dir_default=$HOME/build/build.${target_info}/${project_name} to build_dir_default=/workspace/build/build.${target_info}/${project_name}.

    Note: If you want to modify the build_dir_default, modify $HOME only.
  9. Execute the following command to build the libraries all at once:
    $ cd /workspace/src/vai_library
    $ conda activate base
    $ ./cmake.sh --clean

    After compiling, you can find the generated Vitis AI Library under build_dir_default. If you want to change the compilation rules, check and change the cmake.sh in the library’s directory.