搭建使用TensorRT加速的centerpoint模型环境

github地址:
本文安装的环境是RTX3090+CUDA11.1+CUDNN8.0.5+Pytorch1.8.0+python3.7.0

1、基础安装

# basic python libraries
conda create --name centerpoint python=3.7
conda activate centerpoint
conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge
git clone https://github.com/tianweiy/CenterPoint.git
cd CenterPoint
pip install -r requirements.txt

# add CenterPoint to PYTHONPATH by adding the following line to ~/.bashrc (change the path accordingly)
export PYTHONPATH="${PYTHONPATH}:PATH_TO_CENTERPOINT"

2、安装nuscenes devkit

git clone https://github.com/tianweiy/nuscenes-devkit

# add the following line to ~/.bashrc and reactivate bash (remember to change the PATH_TO_NUSCEnes_DEVKIT value)
export PYTHONPATH="${PYTHONPATH}:PATH_TO_NUSCEnes_DEVKIT/python-sdk"

3、设置CUDA环境

# 加到~/.bashrc里面
export PATH=/usr/local/cuda-11.1/bin:$PATH
export CUDA_PATH=/usr/local/cuda-11.1
export CUDA_HOME=/usr/local/cuda-11.1
export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib64:$LD_LIBRARY_PATH

4、编译

source ~/.bashrc
bash setup.sh

中间编译deform_conv_cuda报错
解决办法:
CenterPoint/det3d/ops/dcn/src/deform_conv_cuda.cpp中用TORCH_CHECK替换掉AT_CHECK

5、安装apex

git clone https://github.com/NVIDIA/apex
cd apex
git checkout 5633f6  # recent commit doesn't build in our system 
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./

6、安装spconv

sudo apt-get install libboost-all-dev
git clone https://github.com/traveller59/spconv.git --recursive
cd spconv && git checkout 7342772
python setup.py bdist_wheel
cd ./dist && pip install *

python setup.py bdist_wheel时报错:

error: no matching function for call to ‘torch::jit::RegisterOperators::RegisterOperators(const char [28], <unresolved overloaded function type>)’

解决办法:
torch::jit::RegisterOperators()替换成torch::RegisterOperators()

7、生成数据集元素

nuscenes数据集目录结构

# For nuScenes Dataset         
└── NUSCEnes_DATASET_ROOT
       ├── samples       <-- key frames
       ├── sweeps        <-- frames without annotation
       ├── maps          <-- unused
       ├── v1.0-trainval <-- Metadata
mkdir data
cd data
mkdir nuScenes
cd nuScenes
#下面使用软连接或者拷贝的方式把前面提到的目录结构放进去
#接着运行以下代码,其中NUSCEnes_TRAINVAL_DATASET_ROOT代表到nuScenes文件夹的路径
python tools/create_data.py nuscenes_data_prep --root_path=NUSCEnes_TRAINVAL_DATASET_ROOT --version="v1.0-trainval" --nsweeps=10

相关文章

本篇内容主要讲解“gitee如何上传代码”,感兴趣的朋友不妨来...
这篇“从gitee上下的代码如何用”文章的知识点大部分人都不太...
这篇文章主要介绍“gitee如何下载仓库里的项目”,在日常操作...
本篇内容主要讲解“怎么在Gitee上更新代码”,感兴趣的朋友不...
本文小编为大家详细介绍“怎么将工程托管到gitee”,内容详细...
这篇文章主要介绍了gitee中图片大小如何调整的相关知识,内容...