Deploy RangeNetTrt8 on ROS2
1. libtorch
tested on CUDA 11.7, libtorch 2.0.1
wget -c https://download.pytorch.org/libtorch/cu117/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcu117.zip
$ unzip libtorch.zip
Ubuntu | GPU | TensorRT | CUDA | cuDNN | — |
---|---|---|---|---|---|
20.04 | TITAN RTX | 8.2.3 | CUDA 11.4.r11.4 | cuDNN 8.2.4 | ✔️ |
20.04 | NVIDIA GeForce RTX 3060 | 8.4.1.5 | CUDA 11.3.r11.3 | cuDNN 8.0.5 | ✔️ |
20.04 (test) | NVIDIA GeForce RTX 3070Ti | 8.4.3.1 | CUDA 11.7.r11.7 | cuDNN 8.9.4.25 | ✔️ |
22.04 | NVIDIA GeForce RTX 3060 | 8.2.5.1 | CUDA 11.3.r11.3 | cuDNN 8.8.0 | ✔️ |
22.04 | NVIDIA GeForce RTX 3060 | 8.4.1.5 | CUDA 11.3.r11.3 | cuDNN 8.8.0 | ✔️ |
Note
Tensorrt > 8.4 may have some running errors
# CUDA
CUDA_PATH=/usr/local/cuda/bin
CUDA_LIB_PATH=/usr/local/cuda/lib64
# TensorRT
export LD_LIBRARY_PATH=${HOME}/TensorRT-8.4.3.1/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=${HOME}/TensorRT-8.4.3.1/lib::$LIBRARY_PATH
# libtorch
export Torch_DIR=${HOME}/libtorch/share/cmake/Torch
export LD_LIBRARY_PATH=${HOME}/libtorch/lib:$LD_LIBRARY_PATH
3. ROS2(Humble)
Note
Debian packages for ROS 2 Humble Hawksbill are currently available for Ubuntu Jammy (22.04).
Source installation is available for Ubuntu Focal (20.04).
sudo apt install build-essential python3-dev python3-pip apt-utils git cmake libboost-all-dev libyaml-cpp-dev libopencv-dev python3-empy
pip install catkin_tools trollius numpy
# mkdir -p ~/ros2_ws/src && cd ~/ros2_ws/src
git clone https://github.com/NeSC-IV/RangeNetTrt8
git clone https://github.com/ros2-gbp/pcl_msgs-release
cd pcl_msgs-release
git checkout release/humble/pcl_msgs
cd ..
git clone https://github.com/ros-perception/perception_pcl.git
cd perception_pcl
git checkout ros2
cd ../.. && colcon build --symlink-install
.
├── RangeNetTrt8
│ ├── model
│ │ ├── arch_cfg.yaml
│ │ ├── data_cfg.yaml
│ │ └── model.onnx
The first run takes a while to generate the TensorRT optimization engine
# >>> ROS2 >>>
cd ~/ros2_ws/
colcon build --symlink-install
source install/setup.bash
ros2 launch rangenet_pp ros2_rangenet.launch
ros2 launch rangenet_pp ros2_bag.launch
❓ 问题 1: [libprotobuf ERROR google/protobuf/text_format.cc:298] Error parsing text-format onnx2trt_onnx.ModelProto: 1:1:
1)情况一:下载的 ONNX 模型不完整,模型解析出问题。重新下载即可。
❓ 问题 2: TensorRT 从 8.2 升级到 8.4 时,预测结果异常,详见 issue#8
不对 235 层的模型权重不进行优化即可