### Download and Prepare Cross-Compiler SDK Source: https://github.com/xilinx/vitis-ai/blob/master/src/vai_runtime/quick_start_for_embedded.md This section details downloading the cross-compiler installation script, making it executable, and then running it. It's recommended to install the SDK in the user's home directory and provides an example of sourcing the environment setup script. The sourced environment is crucial for subsequent cross-compilation steps. ```bash mkdir petalinux_sdk_2023.1 cd petalinux_sdk_2023.1 wget https://www.xilinx.com/bin/public/openDownload?filename=sdk-2023.1.0.0.sh -O sdk-2023.1.0.0.sh chmod +x sdk-2023.1.0.0.sh ./sdk-2023.1.0.0.sh source ~/petalinux_sdk_2023.1/environment-setup-cortexa72-cortexa53-xilinx-linux ``` -------------------------------- ### Run Docker Hello World Source: https://github.com/xilinx/vitis-ai/blob/master/docs/_sources/docs/quickstart/v70.rst.txt Tests the Docker installation by running a 'hello-world' container. This confirms that Docker is installed correctly and can download and run images. ```Bash [Host] $ docker run hello-world ``` -------------------------------- ### Setup Alveo V70 Card Source: https://github.com/xilinx/vitis-ai/blob/master/docs/_sources/docs/quickstart/v70.rst.txt Executes a setup script to install necessary packages for the Alveo V70 card, including XRT, XRM, the V70 platform, and DPU xclbin. This script should be run on the host machine. ```Bash [Host] $ cd /Vitis-AI/board_setup/v70 [Host] $ source ./install.sh ``` -------------------------------- ### Vitis AI Quick Start for Embedded Targets Source: https://github.com/xilinx/vitis-ai/blob/master/docsrc/build/html/docs/workflow-system-integration.html This link provides a quick-start example for deploying Vitis AI Regression (VART) on embedded targets. It's a valuable resource for users looking for a streamlined approach to get VART running on their hardware. ```text https://github.com/Xilinx/Vitis-AI/tree/v3.5/src/vai_runtime/quick_start_for_embedded.md ``` -------------------------------- ### Download Vitis AI Library Example Packages Source: https://github.com/xilinx/vitis-ai/blob/master/docs/_sources/docs/quickstart/vek280.rst.txt Downloads necessary image and video packages for Vitis AI library examples. These packages contain sample data to test the deployed models and library functionalities. ```Bash [Docker] $ cd /workspace [Docker] $ wget https://www.xilinx.com/bin/public/openDownload?filename=vitis_ai_library_r3.5.0_images.tar.gz -O vitis_ai_library_r3.5.0_images.tar.gz [Docker] $ wget https://www.xilinx.com/bin/public/openDownload?filename=vitis_ai_library_r3.5.0_video.tar.gz -O vitis_ai_library_r3.5.0_video.tar.gz ``` -------------------------------- ### Navigate to ResNet50 Example Directory (Bash) Source: https://github.com/xilinx/vitis-ai/blob/master/docsrc/build/html/_sources/docs/quickstart/v70.rst.txt Changes the current directory to the ResNet50 example within the Vitis AI runtime examples. ```Bash [Docker] $ cd /workspace/examples/vai_runtime/resnet50 ``` -------------------------------- ### Download and Extract Vitis AI Runtime Examples Source: https://github.com/xilinx/vitis-ai/blob/master/docs/_sources/docs/quickstart/v70.rst.txt This snippet shows how to download the Vitis AI runtime package for image and video and extract it into a specified directory. This package contains example applications that demonstrate Vitis AI library functionalities. ```Bash [Docker] $ cd ~ [Docker] $ wget https://www.xilinx.com/bin/public/openDownload?filename=vitis_ai_runtime_r3.5.0_image_video.tar.gz -O vitis_ai_runtime_r3.5.0_image_video.tar.gz ``` ```Bash [Docker] $ tar -xzvf vitis_ai_runtime_r3.5.0_image_video.tar.gz -C /workspace/examples/vai_runtime ``` -------------------------------- ### Run ResNet50 Example (Bash) Source: https://github.com/xilinx/vitis-ai/blob/master/docsrc/build/html/_sources/docs/quickstart/v70.rst.txt Executes the compiled ResNet50 example, providing the path to the ResNet50 model file as an argument. ```Bash [Docker] $ ./resnet50 /usr/share/vitis_ai_library/models/resnet50/resnet50.xmodel ``` -------------------------------- ### Run Hello World Docker Container Source: https://github.com/xilinx/vitis-ai/blob/master/docs/_sources/docs/install/install.rst.txt Executes a test container from Docker Hub to verify Docker installation. It downloads a 'hello-world' image and runs it, printing a confirmation message. ```bash docker run hello-world ``` -------------------------------- ### Start Vitis AI Docker Container Source: https://github.com/xilinx/vitis-ai/blob/master/docs/_sources/docs/install/install.rst.txt Launches a Vitis AI Docker container using a pre-built image. The script requires the Vitis-AI installation path and specifies the framework and architecture of the container to run. GPU acceleration is strongly recommended for the quantization process. ```bash cd /Vitis-AI ./docker_run.sh xilinx/vitis-ai--:latest ``` -------------------------------- ### Example Pull Commands for Vitis AI Docker Containers Source: https://github.com/xilinx/vitis-ai/blob/master/docsrc/build/html/_sources/docs/install/install.rst.txt Provides specific examples for pulling different Vitis AI pre-built Docker containers. These include CPU-only and ROCm variants for PyTorch and TensorFlow. ```bash docker pull xilinx/vitis-ai-pytorch-cpu:latest docker pull xilinx/vitis-ai-pytorch-rocm:latest docker pull xilinx/vitis-ai-tensorflow2-cpu:latest docker pull xilinx/vitis-ai-tensorflow2-rocm:latest ``` -------------------------------- ### Compile and Run Vitis AI ResNet50 Example Source: https://github.com/xilinx/vitis-ai/blob/master/docs/_sources/docs/quickstart/v70.rst.txt This snippet outlines the steps to compile and run the ResNet50 example provided with the Vitis AI runtime. It includes changing directory, setting execute permissions for the build script, compiling, and finally executing the compiled application with the model path. ```Bash [Docker] $ cd /workspace/examples/vai_runtime/resnet50 ``` ```Bash [Docker] $ sudo chmod u+r+x build.sh [Docker] $ bash -x build.sh ``` ```Bash [Docker] $ ./resnet50 /usr/share/vitis_ai_library/models/resnet50/resnet50.xmodel ``` -------------------------------- ### Run Vitis-AI Docker Container and Compile Example Source: https://github.com/xilinx/vitis-ai/blob/master/docs/docs/quickstart/vek280.html Launches the Vitis-AI Docker container and activates the PyTorch environment. It then navigates to an example application directory and cross-compiles the target executable. This step validates the host environment setup. ```bash # Navigate to the root Vitis-AI directory on the host cd ../.. # Run the Vitis-AI Docker container (pytorch-cpu version) ./docker_run.sh xilinx/vitis-ai-pytorch-cpu:latest # Inside the Docker container: # Activate the vitis-ai-pytorch conda environment conda activate vitis-ai-pytorch # Navigate to the example application directory cd examples/vai_runtime/resnet50_pt # Make the build script executable sudo chmod u+r+x build.sh # Execute the build script to cross-compile the application bash –x build.sh ``` -------------------------------- ### Install PetaLinux Cross-Compiler Source: https://github.com/xilinx/vitis-ai/blob/master/src/vai_runtime/quick_start_for_embedded.md This snippet demonstrates how to make the PetaLinux installer executable and then run it to install the cross-compiler. The installation destination can be specified, and it is recommended to install it outside of the Vitis AI Docker container. ```bash sudo chmod +x ./petalinux-v2023.1-05012318-installer.run ./petalinux-v2023.1-05012318-installer.run -d ``` -------------------------------- ### Bash: Conda Package Installation Example Source: https://github.com/xilinx/vitis-ai/blob/master/docs/docs/install/Vitis AI 2.5 Aug 2022 Patch.html This bash command demonstrates how to install a conda package into a specified conda environment. It requires the conda environment name and the URL or path to the conda package. ```bash sudo conda install -n ``` -------------------------------- ### Start Specific WSL Distribution Source: https://github.com/xilinx/vitis-ai/blob/master/docs/_sources/docs/quickstart/vek280.rst.txt Starts a specific Linux distribution installed via WSL. This command example launches Ubuntu-20.04. ```Bash wsl -d Ubuntu-20.04 ``` -------------------------------- ### Cross Compile ResNet50 Example in Docker Source: https://github.com/xilinx/vitis-ai/blob/master/docsrc/build/html/docs/quickstart/vek280.html Compiles the resnet50_pt example application within the Vitis-AI Docker container. This step verifies the correct installation of the host environment and the cross-compiler setup. A successful compilation generates the executable file 'resnet50_pt'. ```bash cd examples/vai_runtime/resnet50_pt sudo chmod u+r+x build.sh bash –x build.sh ``` -------------------------------- ### Pull and Run Vitis AI Docker Container Source: https://github.com/xilinx/vitis-ai/blob/master/docs/_sources/docs/quickstart/v70.rst.txt Pulls the Vitis-AI PyTorch CPU Docker image and starts a container. This simplifies the setup by providing a pre-built environment for Vitis-AI examples. ```Bash [Host] $ docker pull xilinx/vitis-ai-pytorch-cpu:latest [Host] $ cd /Vitis-AI/ [Host] $ ./docker_run.sh xilinx/vitis-ai-pytorch-cpu:latest ``` -------------------------------- ### Compile and Run Image Classification Example Source: https://github.com/xilinx/vitis-ai/blob/master/src/vai_library/README.md Navigates to the classification sample directory, compiles the example using the build script, and then runs the image test. Ensure the model and sample image are correctly placed. ```bash cd /workspace/examples/Vitis-AI-Library/samples/classification bash -x build.sh ./test_jpeg_classification resnet50 sample_classification.jpg ``` -------------------------------- ### Setup Alveo V70 Card with Vitis AI Source: https://github.com/xilinx/vitis-ai/blob/master/docsrc/source/docs/quickstart/v70.md Executes a setup script to install necessary components like XRT, XRM, V70 platform, and DPU xclbin for the Alveo V70 card. This script should be run on the host machine outside of Docker. A reboot may be required after execution. ```Shell [Host] $ cd /Vitis-AI/board_setup/v70 [Host] $ source ./install.sh ``` -------------------------------- ### Vitis AI Model Search and Selection Example Source: https://github.com/xilinx/vitis-ai/blob/master/docsrc/build/html/_sources/docs/workflow-model-zoo.rst.txt Demonstrates the interaction with the downloader script. Users input a framework (e.g., 'tf') and a model keyword (e.g., 'resnet'). The script then presents a list of matching models and prompts for a specific selection or to download all matches. ```bash tf resnet ``` ```bash 1 ``` -------------------------------- ### Set up PyTorch Quantization Workspace Source: https://github.com/xilinx/vitis-ai/blob/master/docsrc/source/docs/quickstart/vek280.md This snippet outlines the initial steps for setting up a workspace for PyTorch model quantization using Vitis AI. It includes creating directories and downloading/unzipping a dataset. ```Bash [Host] $ cd ~/Vitis-AI [Host] $ mkdir -p resnet18/model [Host] $ cd resnet18 [Host] $ unzip Archive.zip ``` -------------------------------- ### Setup Host Cross-Compiler Environment Source: https://github.com/xilinx/vitis-ai/blob/master/docs/_sources/docs/quickstart/vek280.rst.txt Sets up the cross-compilation environment on the host machine. This allows for compiling target application code within the Docker container. The script installs the cross-compiler in `~/petalinux_sdk_2023.1` by default. ```Bash cd Vitis-AI/board_setup/vek280 sudo chmod u+r+x host_cross_compiler_setup.sh ./host_cross_compiler_setup.sh ``` -------------------------------- ### Example Vitis-AI Compiler Command with Plugin Source: https://github.com/xilinx/vitis-ai/blob/master/src/vai_runtime/plugin-samples/README.md An example command demonstrating how to invoke the Vitis-AI compiler with a custom plugin. The '--options' flag is used to specify the plugin library. ```shell vai_c_tensorflow -a /opt/vitis_ai/compiler/arch/DPUCAHX8H/U50/arch.json -f quantize_eval_model.pb -n resnet_v1_50 --options '{"plugins": "plugin-demo"}' ``` -------------------------------- ### Generate Sample Input Data for 'add' OP (IPython) Source: https://github.com/xilinx/vitis-ai/blob/master/examples/custom_operator/op_add/README.md Creates sample input binary files ('a.bin', 'b.bin') and a reference output file ('c.bin') using NumPy. 'a.bin' and 'b.bin' contain float32 arrays representing the inputs to the 'add' operation. 'c.bin' contains the expected element-wise sum of 'a' and 'b', serving as the ground truth for verification. ```python import numpy as np a = np.arange(1, 17, dtype=np.float32) b = np.arange(1, 17, dtype=np.float32) a.tofile("/tmp/ref/a.bin") b.tofile("/tmp/ref/b.bin") c = a + b c.tofile("/tmp/ref/c.bin") ``` -------------------------------- ### Compile Vitis AI Example (Bash) Source: https://github.com/xilinx/vitis-ai/blob/master/docsrc/build/html/_sources/docs/quickstart/v70.rst.txt Grants execute permissions to the build script and then executes it to compile the ResNet50 example. ```Bash [Docker] $ sudo chmod u+r+x build.sh [Docker] $ bash -x build.sh ``` -------------------------------- ### Check Docker Version Source: https://github.com/xilinx/vitis-ai/blob/master/docs/_sources/docs/quickstart/v70.rst.txt Displays the installed Docker version to ensure it meets the minimum system requirements. This is a verification step after installing Docker. ```Bash [Host] $ docker --version ``` -------------------------------- ### Run ResNet50 Benchmark Example Source: https://github.com/xilinx/vitis-ai/blob/master/docs/docs/ref_design_docs/README_DPUCV2DX8G.html Executes a benchmark for the ResNet50 model using the 'xdputil benchmark' command. This requires the model file to be copied to the target board and assumes the DPU configuration matches the arch.json file. ```shell cd ~/app/model/ xdputil benchmark resnet50.xmodel 1 ``` -------------------------------- ### Examine XRT Installation Source: https://github.com/xilinx/vitis-ai/blob/master/docs/_sources/docs/quickstart/v70.rst.txt Uses the 'xbutil examine' command to verify the successful installation of the Xilinx Runtime (XRT) and check system configuration, XRT, and detected devices. ```Bash [Host] $ /opt/xilinx/xrt/bin/xbutil examine ``` -------------------------------- ### Run ResNet50 Example Benchmark Source: https://github.com/xilinx/vitis-ai/blob/master/docsrc/build/html/docs/ref_design_docs/README_DPUCV2DX8G.html Executes the ResNet50 example to benchmark the DPU performance. This involves flashing an SD card image, copying the application to the target board, and running the xdputil benchmark command. The output provides performance metrics like FPS. ```shell cd ~/app/model/ xdputil benchmark resnet50.xmodel 1 ``` -------------------------------- ### Install Ubuntu-20.04 on WSL Source: https://github.com/xilinx/vitis-ai/blob/master/docs/_sources/docs/quickstart/vek280.rst.txt Installs the Ubuntu-20.04 distribution for Windows Subsystem for Linux (WSL). This is an optional step for Windows users to evaluate Vitis AI. ```Bash wsl --install -d Ubuntu-20.04 ``` -------------------------------- ### Start TensorBoard Server for Visualization Source: https://github.com/xilinx/vitis-ai/blob/master/examples/OnBoard/README.md This snippet shows how to start the TensorBoard server to visualize the results logged by the OnBoard tool. The user needs to replace '' with the actual log directory path. The server will bind to all interfaces. ```shell tensorboard --logdir= --bind_all ``` -------------------------------- ### Extract Vitis AI Runtime Package (Bash) Source: https://github.com/xilinx/vitis-ai/blob/master/docsrc/build/html/_sources/docs/quickstart/v70.rst.txt Extracts the downloaded Vitis AI runtime package into the specified workspace directory for examples. ```Bash [Docker] $ tar -xzvf vitis_ai_runtime_r3.5.0_image_video.tar.gz -C /workspace/examples/vai_runtime ``` -------------------------------- ### Start Vitis AI Docker Container Source: https://github.com/xilinx/vitis-ai/blob/master/docsrc/build/html/docs/install/install.html This command initiates the Vitis AI Docker container. It requires navigating to the Vitis AI installation directory and executing the docker_run.sh script with specific image tags for the ML framework and hardware target. Ensure the Vitis-AI install path is correctly set. ```shell cd /Vitis\-AI ./docker_run.sh xilinx/vitis\-ai\--:latest ``` -------------------------------- ### Runner Examples Source: https://github.com/xilinx/vitis-ai/blob/master/docsrc/build/html/genindex.html Utility classes for running models and examples. ```APIDOC ## runner_example Class ### Description Example class demonstrating the usage of runner functionalities. ### Method N/A (Python class) ### Endpoint N/A ### Parameters None ### Request Example None ### Response None ## runnerext_example Class ### Description Example class demonstrating extended runner functionalities. ### Method N/A (Python class) ### Endpoint N/A ### Parameters None ### Request Example None ### Response None ``` -------------------------------- ### Run Vitis AI Examples with ResNet50 Source: https://github.com/xilinx/vitis-ai/blob/master/docs/_sources/docs/quickstart/vek280.rst.txt Downloads, extracts, and runs a Vitis AI example, specifically the ResNet50 classification application. This includes transferring runtime packages, navigating directories, and executing the model with a sample image. ```Bash [Host]$scp vitis_ai_runtime_r3.5.0_image_video.tar.gz root@[TARGET_IP_ADDRESS]:~/ [Target] $ cd ~ [Target] $ tar -xzvf vitis_ai_runtime_r3.5.0_image_video.tar.gz -C ~/Vitis-AI/examples/vai_runtime [Target] $ cd ~/Vitis-AI/examples/vai_runtime/resnet50 [Target] $ ./resnet50 /usr/share/vitis_ai_library/models/resnet50/resnet50.xmodel ``` -------------------------------- ### Download and Extract OnBoard Example Recipes Source: https://github.com/xilinx/vitis-ai/blob/master/examples/OnBoard/README.md This snippet downloads and extracts the example recipes for the OnBoard tool, which include models and images necessary for running the examples. It requires wget and tar commands. ```shell wget http://www.xilinx.com/bin/public/openDownload?filename=onboard_example_recipes.tar.gz -O onboard_example_recipes.tar.gz tar -xvf onboard_example_recipes.tar.gz ./ ``` -------------------------------- ### Copy ResNet18 Quantization Script Source: https://github.com/xilinx/vitis-ai/blob/master/docs/_sources/docs/quickstart/v70.rst.txt This command copies the example Vitis-AI ResNet18 quantization script into the workspace. This script utilizes the Quantizer API to perform model quantization. ```Bash [Docker] $ cd .. [Docker] $ cp ../src/vai_quantizer/vai_q_pytorch/example/resnet18_quant.py ./ ``` -------------------------------- ### Build XIR from Source (Linux) Source: https://github.com/xilinx/vitis-ai/blob/master/src/vai_runtime/xir/README.md This command initiates the build process for XIR on a Linux system. It compiles XIR and installs it into the user's local directory. Options are available to customize the build and installation paths. ```bash ./cmake.sh ``` -------------------------------- ### Command Line for Fast Finetuning and Deployment Source: https://github.com/xilinx/vitis-ai/blob/master/src/vai_quantizer/vai_q_pytorch/README.md These command-line examples demonstrate how to execute fast finetuning, test accuracy, and deploy a quantized model using Vitis AI. The `--quant_mode` flag controls calibration or testing, while `--fast_finetune` enables the finetuning process. Additional flags like `--subset_len`, `--batch_size`, and `--deploy` further control the execution for specific scenarios. ```shell # command line to do parameter fast finetuning and re-calibration, python resnet18_quant.py --quant_mode calib --fast_finetune # command line to test fast finetuned quantized model accuracy, python resnet18_quant.py --quant_mode test --fast_finetune # command line to deploy fast finetuned quantized model, python resnet18_quant.py --quant_mode test --fast_finetune --subset_len 1 --batch_size 1 --deploy ``` -------------------------------- ### Source Vitis-AI Environment Setup Source: https://github.com/xilinx/vitis-ai/blob/master/docsrc/build/html/docs/quickstart/vek280.html Activates the cross-compilation environment for Vitis-AI by sourcing the setup script. This command must be executed in every new terminal session before compiling. If you close your terminal, you will need to re-run this command. ```bash source ~/petalinux_sdk_2023.1/environment-setup-cortexa72-cortexa53-xilinx-linux ``` -------------------------------- ### Copy Vitis AI Runtime to Target Board (Bash) Source: https://github.com/xilinx/vitis-ai/blob/master/docsrc/source/docs/workflow-system-integration.md Copies the Vitis AI Runtime setup folder from the host to the target board using SCP. Replace [TARGET] with your board type (e.g., mpsoc, vck190, vek280) and [IP_OF_TARGET] with the board's IP address. This is a prerequisite for installing the runtime on the target. ```Bash scp -r board_setup/[TARGET] root@[IP_OF_TARGET]:~/ ``` -------------------------------- ### List Available WSL Distributions Source: https://github.com/xilinx/vitis-ai/blob/master/docs/_sources/docs/quickstart/vek280.rst.txt Lists all available Linux distributions that can be installed with WSL. Users can select an alternate distribution if it meets the system requirements. ```Bash wsl --list --online ``` -------------------------------- ### Setup Environment Variables and Download Model (Python) Source: https://github.com/xilinx/vitis-ai/blob/master/src/vai_quantizer/tensorflow-onnx/tutorials/efficientnet-lite.ipynb Initializes environment variables, sets the model name, and configures Python path. It also disables CUDA to ensure CPU execution for initial setup. Dependencies include the 'os' module. ```python import os HOME = os.getcwd() MODEL = "efficientnet-lite4" os.environ['PYTHONPATH'] = os.path.join(HOME, "tpu") os.environ['MODEL'] = MODEL os.environ['CUDA_VISIBLE_DEVICES'] = "" ``` -------------------------------- ### Run Example Application (ResNet50 Softmax Runner) Source: https://github.com/xilinx/vitis-ai/blob/master/src/vai_runtime/plugin-samples/samples/plugin-smfc-cpu/README.md This snippet demonstrates how to run the compiled example application. It requires the path to the compiled xmodel and an image path as arguments. This command executes the ResNet50 model using the SoftMax runner on the target. ```sh ./resnet_v1_50_softmax ``` -------------------------------- ### Setup DPU Environment Variables in Docker Source: https://github.com/xilinx/vitis-ai/blob/master/docs/_sources/docs/quickstart/v70.rst.txt Sets up environment variables inside the Docker container for the DPU, using a specific xclbin file that matches the DPU configuration. The chosen xclbin must be in /opt/xilinx/overlaybins. ```Bash [Docker] $ source /workspace/board_setup/v70/setup.sh DPUCV2DX8G_v70 ```