VCK5000运行Vitis-AI3.0WeGO实时量化演示-世界速读

面包芯语   2023-03-24 13:25:02

作者:Shaoyi Chen,AMD开发工程师

xbmgmt examine --report platform --device

输出示例:


【资料图】

如果Flash properties: Type is ospi_versal一定需要更新到ospi_xgq。

只要板卡能被Vivado识别,可以通过下载比特流恢复到这个状态,恢复的方法为:

确认勾选了Erase, Program, and Verify。点击Apply, 然后点击OK。等待烧录完毕即可回到初始状态。

Step 2 卸载已安装的XRT

vck5000_gen4x8_xdma_base_2指定的XRT版本为xrt_202210.2.13.478_18.04-amd64-xrt.deb。如果和这个XRT版本不符,先卸载XRT。

Remove XRT : "sudo apt remove xrt"Remove XRT APU if present : "sudo apt remove xrt-apu"

安装所需的XRTInstall XRT 2.13.478 :https://www.xilinx.com/bin/public/openDownload?filename=xrt_202210.2.13....Install XRT-APU:https://www.xilinx.com/bin/public/openDownload?filename=xrt-apu_202210.2...

安装Gen3和Gen4XDMA平台Install the gen3x16 platform :

https://www.xilinx.com/bin/public/openDownload?filename=xilinx-vck5000-p...

AND install the gen4x8_xdma platform:

https://www.xilinx.com/bin/public/openDownload?filename=xilinx-vck5000-g...

Step 3 更新到xilinx_vck5000_gen3x16_xdma_base_1

将Gen3的镜像烧录到板卡中sudo xbmgmt program --base --device--image

完成后等待一分钟后冷启动电脑。

Step 4 更新到vck5000_gen4x8_xdma_base_2

根据链接可以将VCK5000的platform从vck5000_gen3x16_base_1更新到vck5000_gen4x8_xdma_base_2。https://xilinx.github.io/Alveo-Versal-Platforms/alveoversalplatforms/bui...sudo/opt/xilinx/firmware/vck5000/gen4x8-xdma/base/migration/migrate.sh

完成后等待一分钟后冷启动电脑。

Step 5 更新到vck5000_gen4x8_qdma_base_2

下一步需要更新到vck5000_gen4x8_qdma_base_2,首先安装对应版本的XRT,XRM和XRT-APU,然后烧写platform,注意安装版本要和vitis-ai 3.0匹配。

安装XRThttps://www.xilinx.com/bin/public/openDownload?filename=xrt_202220.2.14....

安装XRMhttps://www.xilinx.com/bin/public/openDownload?filename=xrm_202220.1.5.2...

安装vck5000_gen4X8_qdma平台

wgethttps://www.xilinx.com/bin/public/openDownload?filename=xilinx-vck5000-g...

tar xfz shell.tgzsudo apt install ./xilinx-vck5000-gen4x8-qdma-base_2-20221205_all.deb -y

第一步,只能更新shell。sudo /opt/xilinx/xrt/bin/xbmgmt program --device 01:00.0 --base shell --image xilinx_vck5000_gen4x8_qdma_base_2

升级完成后等待一分钟冷启动,由于没有更新SC会出现

将SC版本从4.4.33更新到4.4.35 需要更新两次。第一次更新SC会以失败告终。

等待一分钟后再次烧录SC

再等待一分钟后冷启动电脑,然后检查板卡状态。

到此更新完毕。

Part2 运行Vitis-AI 3.0 demo

获取Vitis-AI仓库。

git clone;

以Pytorch为例子,获取docker容器。

docker pull xilinx/vitis-ai-pytorch-cpu:latest

查询系统中存在的容器

docker images

启动容器。

根据DPU型号设置vck5000脚本,脚本在setup_board/vck5000目录下source ./setup.sh DPUCVDX8H_4pe_miscdwcsource ./setup.sh DPUCVDX8H_6pe_dwcsource ./setup.sh DPUCVDX8H_6PE_MISCsource ./setup.sh DPUCVDX8H_8pe_normal

该脚本会设置两个环境变量XCLBIN_PATH = /opt/xilinx/overlaybins/DPUCVDX8H/4PEXLNX_VART_FIRMWARE = /opt/xilinx/overlaybins/DPUCVDX8H/4PE/dpu_DPUCVDX8H_4PE_350M_xilinx_vck5000_ge

准备数据集

To use ImageNet, first download it fromhttp://www.image-net.org/. For calibration purpose, only the validation set is needed.

数据集结构# imagenet/train/# ├── n01440764# │ ├── n01440764_10026.JPEG# │ ├── n01440764_10027.JPEG# │ ├── ......# imagenet/val/# ├── n01440764# │ ├── ILSVRC2012_val_00000293.JPEG# │ ├── ILSVRC2012_val_00002138.JPEG# │ ├── ......# ├── ......

安装必要的包pip install -r requirements.txt

准备浮点模型wget;

准备测试图像wget -O wego_example_recipes.tar.gz

tar xf wego_example_recipes.tar.gz -C /tmp

运行脚本bash quantize_compile_serialize_run.sh ./inception_v3_google-0cc3c7bd.pth ./val

可以得到最终的结果

bash quantize_compile_serialize_run.sh ./inception_v3_google-0cc3c7bd.pth ./testval/

出现错误Traceback (most recent call last):File "run.py", line 181, inmain()File "run.py", line 166, in mainwego_mod = get_wego_mod(img_transforms)File "run.py", line 125, in get_wego_modquantized_model = wego_torch.quantize(float_model, [[target_batch] + input_shape], calib_dataloader, calibrator)File "/opt/vitis_ai/conda/envs/vitis-ai-wego-torch/lib/python3.7/site-packages/wego_torch/quantizer.py", line 130, in quantizefor b_idx, batch in tqdm(enumerate(dataloader), total=len(dataloader)):File "/opt/vitis_ai/conda/envs/vitis-ai-wego-torch/lib/python3.7/site-packages/tqdm/std.py", line 1195, in __iter__for obj in iterable:File "/opt/vitis_ai/conda/envs/vitis-ai-wego-torch/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 681, in __next__data = self._next_data()File "/opt/vitis_ai/conda/envs/vitis-ai-wego-torch/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 721, in _next_datadata = self._dataset_fetcher.fetch(index) # may raise StopIterationFile "/opt/vitis_ai/conda/envs/vitis-ai-wego-torch/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetchdata = [self.dataset[idx] for idx in possibly_batched_index]File "/opt/vitis_ai/conda/envs/vitis-ai-wego-torch/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 49, indata = [self.dataset[idx] for idx in possibly_batched_index]File "/opt/vitis_ai/conda/envs/vitis-ai-wego-torch/lib/python3.7/site-packages/torch/utils/data/dataset.py", line 290, in __getitem__return self.dataset[self.indices[idx]]File "/opt/vitis_ai/conda/envs/vitis-ai-wego-torch/lib/python3.7/site-packages/torchvision/datasets/folder.py", line 229, in __getitem__path, target = self.samples[index]IndexError: list index out of range

请往数据集添加更多的测试数据。

2.更新VCK5000到xilinx_vck5000_gen4x8_xdma_base_2出错

EXE: /opt/xilinx/xrt/bin/unwrapped/xbmgmt2[xbmgmt] ERROR: Failded to update base: Invalid argument

检查platform是否存已经安装且名字输入正确。

联系FAE回退到Gen3X16,重新升级。

最新资讯