本文代码Github地址:GitHub - PRBonn/rangenet_lib: Inference module for RangeNet++ (milioto2019iros, chen2019iros)
原文地址:https://www.ipb.uni-bonn.de/wp-content/papercite-data/pdf/milioto2019iros.pdf
目录
一、环境配置
1.Cuda11.6
2.cudnn安装
3.TensorRT安装
二、RangeNet++源码编译
运行demo
Ubuntu20.04+Cuda11.6+cudnn8.4.1+TensorRT-8.4.1.5
官网下载:CUDA Toolkit Archive | NVIDIA Developer
wget https://developer.download.nvidia.com/compute/cuda/11.6.0/local_installers/cuda_11.6.0_510.39.01_linux.run
sudo sh cuda_11.6.0_510.39.01_linux.run
开始安装,取消安装驱动,其余默认(y)安装
环境变量配置
gedit ~/.bashrc
变量生效
source ~/.bashrc
验证版本
nvcc -V
官网下载(需要登陆):CUDA Deep Neural Network (cuDNN) | NVIDIA Developer
选择Archived cuDNN Releases
将解压出的文件,移动到/usr/local/cuda文件夹下:(根据自己的路径进行修改)
sudo cp -P /home/yang/下载/cudnn-linux-x86_64-8.4.1.50_cuda11.6-archive/lib/libcudnn* /usr/local/cuda-11.6/lib64/
sudo cp /home/yang/下载/cudnn-linux-x86_64-8.4.1.50_cuda11.6-archive/include/cudnn.h /usr/local/cuda-11.6/include/
赋予所有用户权限,cudnn安装完成
sudo chmod a+r /usr/local/cuda-11.6/include/cudnn.h
sudo chmod a+r /usr/local/cuda-11.6/lib64/libcudnn*
验证cudnn
cat /usr/local/cuda-11.6/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
官网下载地址:https://developer.nvidia.com/nvidia-tensorrt-download
如果Cuda下载用的是deb(local),则TensorRT也需要下载Debian包本地安装;而Cuda用runfile安装,就得下载tar压缩安装;两者需要对应,否则安装会报错。
下载完成后,解压到本地
把 TensorRT 的库和头文件添加到系统路径下:
# TensorRT目录下
sudo cp -r ./lib/* /usr/lib
sudo cp -r ./include/* /usr/include
添加路径到环境变量
gedit ~/.bashrc
export LD_LIBRARY_PATH=/home/yang/tensorrt/TensorRT-8.4.1.5/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=/home/yang/tensorrt/TensorRT-8.4.1.5/lib::$LIBRARY_PATH
source ~/.bashrc
测试
#在TensorRt目录文件夹下,cd到sample文件夹下
sudo make
cd ../bin
./sample_mnist
如果还要用Python接口:
#在下载的TensorRT目录文件夹下
cd TensorRT-8.4.1.5/python
pip install tensorrt-8.4.1.5/-py2.py3-none-any.whl
# 安装UFF,支持tensorflow模型转化
cd TensorRT-8.4.1.5//uff
pip install uff-0.5.5-py2.py3-none-any.whl
# 安装graphsurgeon,支持自定义结构
cd TensorRT-8.4.1.5//graphsurgeon
pip install graphsurgeon-0.3.2-py2.py3-none-any.whl
python接口验证
python3
import tensorrt
tensorrt.__version__
#输出'8.4.1.5'则安装成功!
相关依赖安装
sudo apt-get update
sudo apt-get install -yqq build-essential python3-dev python3-pip apt-utils git cmake libboost-all-dev libyaml-cpp-dev libopencv-dev
sudo apt install python3-empy
sudo pip install catkin_tools trollius numpy
使用 catkin 工具来构建库,终端打开:
mkdir -p ~/catkin_rangenet/src
cd ~/catkin_rangenet/src
git clone https://github.com/ros/catkin.git
git clone https://github.com/PRBonn/rangenet_lib.git
cd .. && catkin init
catkin build rangenet_lib
预训练模型下载:https://www.ipb.uni-bonn.de/html/projects/semantic_suma/darknet53.tar.gz
# cd到catkin workspace下
cd ~/catkin_rangenet
# -p后是预训练模型路径、-s后是要预测点云.bin demo路径
./devel/lib/rangenet_lib/infer -p /path/to/the/pretrained/model -s /path/to/the/scan.bin --verbose
需要花点时间,请耐心等待。