OpenPCDet源码链接:
官方源码:https://gitcode.com/mirrors/open-mmlab/OpenPCDet/tree/master
官方首页介绍:https://gitcode.com/mirrors/open-mmlab/OpenPCDet/overview
一:重新配置conda环境
1.1.安装cuda
1.1.1官网安装
官网地址:CUDA官网安装步骤
根据网页提示,只执行以下命令(以安装CUDA12.6为例):
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/12.6.1/local_installers/cuda-repo-ubuntu2204-12-6-local_12.6.1-560.35.03-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2204-12-6-local_12.6.1-560.35.03-1_amd64.deb
sudo cp /var/cuda-repo-ubuntu2204-12-6-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda-toolkit-12-6
1.1.2 更新环境
打开终端,配置环境变量:
vim ~/.bashrc
最后一行后添加:
export PATH=$PATH:/usr/local/cuda-12.6/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-12.6/lib64
退出vim:
:wq
打开终端输入:
source ~/.bashrc
1.1.3 查看已安装版本
nvcc -V
nvcc --version
nvidia-smi
1.2.安装conda
1.3 配置OpenPCDet环境
1.3.1创建OpenPCDet虚拟环境
conda create -n OpenPCDetTest python=3.8 -y
conda activate OpenPCDetTest
1.3.2 安装Pytorch
显示安装的cuda版本
nvcc -V
nvcc --version
根据cuda版本安装相应的pytorch
# CUDA 11.8
conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=11.8 -c pytorch -c nvidia
# CUDA 12.1
conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=12.1 -c pytorch -c nvidia
# CUDA 12.4
conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=12.4 -c pytorch -c nvidia
# CPU Only
conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 cpuonly -c pytorch
# 查看torch的版本
python -c 'import torch;print(torch.__version__)'
python -c 'import torch;print(torch.cuda.is_available())'
1.3.3 安装cudatoolkit和cudnn
具体cuda版本及需要的内核详见:CUDA Toolkit and Corresponding Driver Versions cudatoolkit官网
最新NVIDIA官网cuda与cudnn对应的版本cudnn对应版本官网
搜索 cudatoolkit 和 cudnn 的可用版本:
conda search cudnn
conda search cudatoolkit
安装:
CUDA 10.2
conda install cudatoolkit=10.2.89 cudnn==7.6.5 -c http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
CUDA 11.3
conda install cudatoolkit=11.3.1 cudnn==8.2.1 -c http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
CUDA 12.1
conda install cudatoolkit=11.8.0 cudnn==8.9.2.26 -c nvidia -c http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
1.3.4 安装spconv
pip install spconv-cu102 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install spconv-cu113 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install spconv-cu120 -i https://pypi.tuna.tsinghua.edu.cn/simple
python -c 'import spconv;print(spconv.__version__)'
1.3.5 安装torch-scatter
pip install torch-scatter -f https://pytorch-geometric.com/whl/1.12.1+cu113.html
pip install torch-scatter -f https://pytorch-geometric.com/whl/1.12.1+cu121.html
1.3.6 安装torch-scatter
pip install torch-scatter -f https://pytorch-geometric.com/whl/1.12.1+cu113.html
1.3.7 安装open3d
pip install open3d -i https://pypi.tuna.tsinghua.edu.cn/simple
python -c 'import open3d;print(open3d.__version__)'
二、导入已有conda环境
导出conda环境:
conda env export > OpenPCDetTest.yaml
使用yaml文件创建一个新的conda环境:
conda env create -f OpenPCDetTest.yaml
三、安装OpenPCDet
git clone https://github.com/open-mmlab/OpenPCDet.git
cd OpenPCDet
pip install -r requirements.txt -i httPs://pypi.tuna.tsinghua.edu.cn/simple
pip install kornia==0.6.8 av2 chardet -i httPs://pypi.tuna.tsinghua.edu.cn/simple
python setup.py develop
python -c 'import pcdet;print(pcdet.__version__)'
四、运行Demo程序
1、数据准备
1 、在OpenPCDet/data/kitti/文件夹下准备testing/000001.bin文件;
2、 在OpenPCDet/tools/文件夹下准备pointpillar_7728.pth 、 pv_rcnn_8369.pth 预训练模型;
3、 如果demo.py程序中,加入了调试文件,则加入到相对应的目录下。
2、PV-RCNN ~5 hours 83.61 57.90 70.47 model-50M
python demo.py --cfg_file cfgs/kitti_models/pv_rcnn.yaml --ckpt pv_rcnn_8369.pth --data_path ../data/kitti/testing/000001.bin
3、PointPillar ~1.2 hours 77.28 52.29 62.68 model-18M
python demo.py --cfg_file cfgs/kitti_models/pointpillar.yaml --ckpt pointpillar_7728.pth --data_path ../data/kitti/testing/000001.bin
参考资料:
https://blog.csdn.net/takedachia/article/details/130375718
https://gitcode.com/mirrors/open-mmlab/OpenPCDet/blob/master/docs/INSTALL.md
https://blog.csdn.net/Williamcsj/article/details/123915652
https://blog.csdn.net/qq_40600379/article/details/131950614