搭建使用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

上一篇:Ubuntu18.04 安装cuda-10.2 cudnn7.6.5.32 tensorrt7.0.0.11


下一篇:Angular中依赖注入方式的几种写法