BEVFustion-TensorRT部署

BEVFustion-TensorRT部署

1 下载Lidar_AI_Solution

  • 不要去直接点击 DownZIP 下载,也不要直接 git clone 下载,因为该项目依赖于其他项目,因此加上 --recursive 参数是为了循环克隆子项目。
git clone --recursive https://github.com/NVIDIA-AI-IOT/Lidar_AI_Solution.git
  • 如果上面下载失败,请采用下面下载方式
  1. 下载速度慢,用国内代理拉取
# 下载Lidar_AI_Solution,不含子模块
git clone https://ghproxy.com/https://github.com/NVIDIA-AI-IOT/Lidar_AI_Solution.git

# 进入目录, 修改`.gitmodules`文件
cd Lidar_AI_Solution

# 国内代理https://ghproxy.com/
  1. .gitmodules中url加上代理https://ghproxy.com/ 如下所示
[submodule "CUDA-PointPillars"]
path = CUDA-PointPillars
url = https://ghproxy.com/https://github.com/NVIDIA-AI-IOT/CUDA-PointPillars.git
[submodule "CUDA-BEVFusion/bevfusion"]
path = CUDA-BEVFusion/bevfusion
url = https://ghproxy.com/https://github.com/mit-han-lab/bevfusion.git
[submodule "dependencies/pybind11"]
path = dependencies/pybind11
url = https://ghproxy.com/https://github.com/pybind/pybind11.git
[submodule "dependencies/stb"]
path = dependencies/stb
url = https://ghproxy.com/https://github.com/nothings/stb.git
[submodule "libraries/cuPCL"]
path = libraries/cuPCL
url = https://ghproxy.com/https://github.com/NVIDIA-AI-IOT/cuPCL.git
  1. 下载子模块
git submodule sync && git submodule update --init --recursive
  • 整个包大约336.3 MB, 包含子模块。如果不是请重新下载

Git LFS(Large File Storage,大型文件存储)。当一个项目的最大文件超过128MB,那么Git就会报错

2 BEVFusion的TensorRT部署

2.1 BEVFusion环境

  • 不要问其他版本行不行,小白和不想折腾的小伙伴直接抄作业:

  • 版本号:ubuntu20.04, 显卡驱动525(影响不大),cuda-11.3, cudnn-8.6.0,TensorRT-8.5.3.1

  • 这个BEVFusion源码地址mit版本

  • 安装其他依赖:

sudo apt install libprotobuf-dev cmake
pip install onnx
  • 如果不是ubuntu20.04libprotobuf-dev版本可能小于3.6.1版本,可以去git上下载源码编译安装 ,git地址

readme.md要求的版本:

To build bevfusion, we need to depend on the following libraries:
- CUDA >= 11.0
- CUDNN >= 8.2
- TensorRT >= 8.5.0
- libprotobuf-dev == 3.6.1
- [Compute Capability](https://developer.nvidia.com/cuda-gpus#compute) >= sm_80
- Python >= 3.6

2.2 下载权重以及测试图像

文档参考

  1. 模型下载解压后复制到Lidar_AI_Solution/CUDA-BEVFusion/中,目录结果如下:
(base) lin@PC:~/Lidar_AI_Solution/CUDA-BEVFusion/model$ tree
.
├── resnet50
│   ├── bevfusion-det.pth
│   ├── camera.backbone.onnx
│   ├── camera.vtransform.onnx
│   ├── default.yaml
│   ├── fuser.onnx
│   ├── head.bbox.onnx
│   └── lidar.backbone.xyz.onnx
├── resnet50int8
│   ├── bevfusion_ptq.pth
│   ├── camera.backbone.onnx
│   ├── camera.vtransform.onnx
│   ├── default.yaml
│   ├── fuser.onnx
│   ├── head.bbox.onnx
│   └── lidar.backbone.xyz.onnx
└── swint
    ├── camera.backbone.onnx
    ├── camera.vtransform.onnx
    ├── default.yaml
    ├── fuser.onnx
    ├── head.bbox.onnx
    └── lidar.backbone.xyz.onnx

2 测试数据下载解压后复制到Lidar_AI_Solution/CUDA-BEVFusion/中,目录结果如下:

(bevfusion) lin@PC:~/Lidar_AI_Solution/CUDA-BEVFusion/example-data$ tree
├── 0-FRONT.jpg
├── 1-FRONT_RIGHT.jpg
├── 2-FRONT_LEFT.jpg
├── 3-BACK.jpg
├── 4-BACK_LEFT.jpg
├── 5-BACK_RIGHT.jpg
├── camera2ego.tensor
├── camera2lidar.tensor
├── camera_intrinsics.tensor
├── example-data.pth
├── gt_bboxes_3d.tensor
├── gt_labels_3d.tensor
├── images.tensor
├── img_aug_matrix.tensor
├── lidar2camera.tensor
├── lidar2ego.tensor
├── lidar2image.tensor
├── lidar_aug_matrix.tensor
├── points.tensor
└── token.txt

3 运行

  • 报错1:运行./tool/build_trt_engine.sh报错

😥Failed to build model model/resnet50int8/build/camera.backbone.plan.

  • 更换TensorRT版本, 即修改CUDA-BEVFusion/tool/environment.sh中的TensorRT的设置,本人的如下:
export TensorRT_Lib=/home/lin/software/TensorRT-8.5.3.1/lib
export TensorRT_Inc=/home/lin/software/TensorRT-8.5.3.1/include
export TensorRT_Bin=/home/lin/software/TensorRT-8.5.3.1/bin
  • 报错2:运行./tool/run.sh报错
    😥nvcc fatal : Unsupported gpu architecture 'compute_89'

修改,在tool/environment.sh最后更新nvcc支持的算力,将export CUDASM=86代码复制到tool/environment.sh文件的最后一行即可

  • cuda-11.3最高支持8.6
    由于我的显卡是6000系,算力是8.940显卡系可能也会遇到这个问题,40系的算力也是8.9, 30系卡算力是8.6,如果你使用cuda-11.x版本就改CUDASM参数,要么更改为cuda-12.0版本

  • 改成cuda-12.0版本的方法是否能运行还未测试,建议直接改CUDASM

export CUDASM=86

  1. 增加脚本文件的可执行权限
# 1 进入CUDA-BEVFusion目录
cd CUDA-BEVFusion

# 2 给tools目录下所有文件加权限
chmod +x ./tools/*
  1. 运行tool/environment.sh
  • 设置cuda, cudnn, TensorRT的环境变量, 土话将就是告诉编译器去哪里找这三个库

  • 运行前需要修改这个3个库安装目录, 大家根据自己实际情况修改,本人的如下:

  • 模型3种 ,精度2种, 选择其中一种

  • 设置参数

# TensorRT-8.2.1.8
export TensorRT_Lib=/home/lin/software/TensorRT-8.5.3.1/lib
export TensorRT_Inc=/home/lin/software/TensorRT-8.5.3.1/include
export TensorRT_Bin=/home/lin/software/TensorRT-8.5.3.1/bin

# cuda
export CUDA_Lib=/usr/local/cuda/lib64
export CUDA_Inc=/usr/local/cuda/include
export CUDA_Bin=/usr/local/cuda/bin
export CUDA_HOME=/usr/local/cuda

# 由于安装cudnn是时将cudnn的lib64拷贝到cuda下的,所以这里直接用cuda的路径
export CUDNN_Lib=/usr/local/cuda/lib64

# 选择模型三种 resnet50/resnet50int8/swint
export DEBUG_MODEL=resnet50int8

# 精度2种 fp16/int8
export DEBUG_PRECISION=int8
  • 运行:
./tool/environment.sh

显示如下:
在这里插入图片描述

  1. 运行tool/build_trt_engine.sh
./tool/build_trt_engine.sh

显示如下:
在这里插入图片描述
4. 运行tool/run.sh

./tool/run.sh

显示如下:
在这里插入图片描述
可以看到resnet50int8推理耗时只要5.4ms左右,从可视化上看效果也还行,YYDS

效果图展示:
在这里插入图片描述

小伙伴们部署时遇到问题,欢迎各位小伙伴留言,欢迎进入bev交流抠抠裙472648720,大家一起学bev!
如果觉得文章可以,一键三连支持一波,瑞思拜^-^
参考链接

  • 10
    点赞
  • 43
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 17
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 17
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

全网最菜的Slamer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值