文件最后提交记录最后更新时间
!6738 更新了mx_driving.data改为.preprocess Merge pull request !6738 from 李林斯曼/master 1 年前
!6102 [built-in][PyTorch][CenterPoint] Commit npu adaptation for CenterPoint in OpenPCDet Merge pull request !6102 from 丛臻/master 2 年前
!6605 add npu adaption updates of CenterPoint2D Merge pull request !6605 from zhangchenrui/master 1 年前
!6074 PyTorch 2.2 版本依赖配套更新 Merge pull request !6074 from Chai/master 2 年前
!6349 PyTorch 2.3 版本依赖配套更新 Merge pull request !6349 from 周嘉益/master 1 年前
!6574 PyTorch 2.4 版本依赖配套更新 Merge pull request !6574 from 周嘉益/pt24 1 年前
!6039 [Pytorch][built-in][ autonoumous_driving ]Add OpenPCDet source code Merge pull request !6039 from 陈小龙/master 2 年前
文档整改,gitee->gitcode Co-authored-by: Lighters_c<zyh13227@163.com> # message auto-generated for no-merge-commit merge: !7469 merge ffffix into master 文档整改,gitee->gitcode Created-by: addsubmuldiv Commit-by: Lighters_c Merged-by: ascend-robot Description: ## Motivation Please describe the motivation of this PR and the goal you want to achieve through this PR. ## Modification Please briefly describe what modification is made in this PR. ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!74695 个月前
!7376 optimize public_address_statement.md Merge pull request !7376 from 王凯宇/master 8 个月前
!6608 更新BEVFormer模型资料信息&openPCDet模型requirements Merge pull request !6608 from 王世豪/master 1 年前
!6045 [Pytorch][built-in][OpenPCDet] Adapt the PointPillar model to use the NPU accelerator Merge pull request !6045 from 陈小龙/cxl 2 年前
README.md

当前仓已不维护,请跳转至 https://gitcode.com/ascend/DrivingSDK/tree/master/model_examples/

OpenPCDet for Pytorch

概述

OpenPCDet 是一个基于 LiDAR 的 3D 物体检测套件,包含PointPillar、PointRCNN、CenterPoint等多种自动驾驶模型。本仓库对 OpenPCDet 中的部分模型进行了NPU设备的适配。

  • 参考实现:
https://github.com/open-mmlab/OpenPCDet.git
commit_id=255db8f02a8bd07211d2c91f54602d63c4c93356
  • 适配昇腾AI处理器的实现:
url=https://gitcode.com/ascend/ModelZoo-PyTorch.git
code_path=PyTorch/built-in/autonoumous_driving

模型适配情况

支持模型 支持数据集
PointPillar Kitti
Centerpoint Nuscenes

Centerpoint

准备环境

1. 基本环境准备

在模型源码包所在目录下执行相应命令,安装模型需要的依赖

cd ./OpenPCDet
pip install -r requirements.txt && cd ../   # PyTorch 2.1版本

2. 手动编译安装cumm和spconv

在开始安装前,确保系统已安装GCC 7.5.0

2.1 前置依赖安装

执行以下命令,安装前置依赖pccm==0.3.4,ccimport==0.3.7

pip install pccm==0.3.4
pip install ccimport==0.3.7

2.2 编译安装cumm

执行以下命令编译安装cumm

git clone https://github.com/FindDefinition/cumm.git -b v0.2.9
export CUMM_CUDA_VERSION=""
export CUMM_DISABLE_JIT="1"
cd ./cumm/
python setup.py bdist_wheel
cd ../ && pip install cumm/dist/cumm-*.whl 

【注意】安装完毕后建议运行以下命令,如无报错,证明安装无误,可继续安装流程

python -c "import cumm"

2.3 编译安装spconv

  1. 执行以下命令,拉取spconv源码用于本地编译

    git clone https://github.com/traveller59/spconv.git -b v2.1.25
    
  2. 执行以下命令,删除冗余文件

    rm -rf spconv/spconv/core_cc/csrc/sparse/all/ops1d.pyi
    rm -rf spconv/spconv/core_cc/csrc/sparse/all/ops2d.pyi
    rm -rf spconv/spconv/core_cc/csrc/sparse/all/ops3d.pyi
    rm -rf spconv/spconv/core_cc/csrc/sparse/all/ops4d.pyi
    rm -rf spconv/spconv/core_cc/cumm/tools/
    rm -rf spconv/pyproject.toml
    
  3. 执行以下命令,替换spconv三方库中的文件内容

    /bin/cp -rf OpenPCDet/third_party_patches/spconv_patches/spconv/core_cc/csrc/sparse/all/__init__.pyi spconv/spconv/core_cc/csrc/sparse/all/__init__.pyi
    
  4. 将spconv/spconv/pytorch/ops.py文件第32行代码进行调整

    # 将代码 if hasattr(_ext, "cumm"):
    # 调整为 if 0:
    
  5. 注释spconv/spconv/utils/__init__.py文件第26-30行代码

    if not CPU_ONLY_BUILD:
        from spconv.core_cc.csrc.sparse.all.ops1d import Point2Voxel as Point2VoxelGPU1d
        from spconv.core_cc.csrc.sparse.all.ops2d import Point2Voxel as Point2VoxelGPU2d
        from spconv.core_cc.csrc.sparse.all.ops3d import Point2Voxel as Point2VoxelGPU3d
        from spconv.core_cc.csrc.sparse.all.ops4d import Point2Voxel as Point2VoxelGPU4d
    
  6. 执行以下命令编译安装spconv

    export SPCONV_DISABLE_JIT="1"
    cd ./spconv/
    python setup.py bdist_wheel
    cd ../ && pip install spconv/dist/spconv-*.whl
    

    【注意】安装完毕后建议运行以下命令,如无报错,证明安装无误,可继续安装流程

    python -c "import spconv"
    

2.4 编译安装pytorch-scatter

执行以下命令编译安装pytorch-scatter

git clone https://github.com/rusty1s/pytorch_scatter.git -b 2.1.1
cd ./pytorch_scatter/
python setup.py bdist_wheel
cd ../ && pip install pytorch_scatter/dist/torch_scatter-*.whl

【注意】安装完毕后建议运行以下命令,如无报错,证明安装无误,可继续安装流程

python -c "import torch_scatter"

2.5 编译安装mxDriving

参考mxDriving官方gitcode仓README安装编译构建并安装mxDriving包:参考链接

【注意】当前版本配套mxDriving RC3及以上版本,历史mxDriving版本需要model仓代码回退到git reset --hard 91ac141ecfe5872f4835eef6aa4662f46ede80c3 【注意】安装完毕后建议运行以下命令,如无报错,证明安装无误,可继续安装流程

python -c "import mx_driving"

2.6 编译安装OpenPCDet

执行以下命令,编译安装OpenPCDet

cd ./OpenPCDet/
python setup.py develop

准备数据集

  1. 下载nuScenes数据集,请自行前往nuScenes官方网站下载3D目标检测数据集
  2. 下载训练数据集data目录
    1. 克隆OpenPCDet源码:git clone https://github.com/open-mmlab/OpenPCDet.git
    2. 将OpenPCDet源码的data目录复制到本仓的OpenPCDet工程目录下
  3. 下载解压的nuScenes数据集,并按照如下方式组织:
    OpenPCDet
    ├── data
    │   ├── nuscenes
    │   │   │── v1.0-trainval (or v1.0-mini if you use mini)
    │   │   │   │── samples
    │   │   │   │── sweeps
    │   │   │   │── maps
    │   │   │   │── v1.0-trainval  
    ├── pcdet
    ├── tools
    
  4. 安装数据处理相关依赖
    pip install nuscenes-devkit==1.0.5
    pip install av2
    pip install kornia==0.5.8
    pip install opencv-python-headless --force-reinstall
    
  5. 执行数据预处理脚本,生成序列化数据集
    cd ./OpenPCDet/
    python -m pcdet.datasets.nuscenes.nuscenes_dataset --func create_nuscenes_infos --cfg_file tools/cfgs/dataset_configs/nuscenes_dataset.yaml --version v1.0-trainval
    

模型训练

  1. 进入OpenPCDet的根目录。
    cd ./OpenPCDet/
    
  2. numpy版本降级为1.23.5 执行以下命令,将numpy版本降级为1.23.5,过高的numpy版本会导致代码中numpy部分被废弃用法不可用
    pip install numpy==1.23.5
    
  3. 运行训练脚本。 该模型支持单机单机8卡训练
    cd tools/test
    bash train_centerpoint_full_8p.sh # 8p精度训练
    bash train_centerpoint_performance_8p.sh # 8p性能训练
    
    训练完成后,权重文件保存在当前路径下,并输出模型训练精度和性能信息

训练结果对比

精度

训练精度结果展示表

Exp mATE mASE mAOE mAVE mAAE mAP NDS
8p-竞品A 32.59 26.35 44.26 24.50 19.30 49.20 59.78
8p-Atlas 800T A2 32.50 26.34 45.05 24.23 19.39 50.06 60.45

性能

训练性能结果展示表

Exp FPS
8p-竞品A 10.714
8p-Atlas 800T A2 8.270

说明:上表为历史数据,仅供参考。2024年12月31日更新的性能数据如下:

NAME 精度类型 FPS
pointpillar 8p-竞品 FP16 51
pointpillar 8p-Atlas 900 A2 PoDc FP16 64
centerpoint 8p-竞品 FP32 10.714
centerpoint 8p-Atlas 900 A2 PoDc FP32 11.8

PointPillar

准备环境

  • 推荐参考配套资源文档使用最新的配套版本。

    表 1 版本配套表

    软件 版本 安装指南
    Driver AscendHDK 24.1.RC3 驱动固件安装指南
    Firmware AscendHDK 24.1.RC3
    CANN CANN 8.0.RC3 CANN 软件安装指南
    PyTorch 2.1.0 Ascend Extension for PyTorch 配置与安装
    torch_npu release v6.0.rc3
  • 三方库依赖如下表所示。

    表 2 三方库依赖表

    Torch_Version 三方库依赖版本
    PyTorch 2.1.0 torchvision 0.16.0
  • 环境准备指导。

    请参考《Pytorch框架训练环境准备》。

  • 安装依赖。

    1. 基本环境

    在模型源码包根目录下执行相应命令,安装模型需要的依赖。

    conda create -n env_name python=3.8
    pip install -r requirements.txt    # PyTorch 2.1版本
    

    2. 手动编译安装cumm和spconv

    手动编译安装cumm==0.2.9,spconv=2.1.25。需要安装指定版本GCC,版本为GCC 7.5.0

    1. 编译安装cumm
      git clone https://github.com/FindDefinition/cumm.git -b v0.2.9
      export CUMM_CUDA_VERSION=""
      export CUMM_DISABLE_JIT="1"
      cd cumm/
      python setup.py bdist_wheel
      pip install dist/cumm-xxx.whl  # cumm包名在不同系统有差异
      
    2. 编译安装spconv
      git clone https://github.com/traveller59/spconv.git -b v2.1.25
      # 1.删除spconv工程目录下pyproject.toml
      # 2.修改spconv工程目录下setup.py内REQUIRED = []
      # 3.注释掉spconv/core_cc/csrc/sparse/all/__init__.pyi中所有代码
      # 4.export环境变量
      export SPCONV_DISABLE_JIT="1"
      python setup.py bdist_wheel
      pip install dist/spconv-xxx.whl  # spconv包名在不同系统有差异
      # 修改安装后的的spconv(在自己conda env环境的site-packages内),注释掉spconv/utils/__init__.py以下代码
      if not CPU_ONLY_BUILD:
         from spconv.core_cc.csrc.sparse.all.ops1d import Point2Voxel as Point2VoxelGPU1d
         from spconv.core_cc.csrc.sparse.all.ops2d import Point2Voxel as Point2VoxelGPU2d
         from spconv.core_cc.csrc.sparse.all.ops3d import Point2Voxel as Point2VoxelGPU3d
         from spconv.core_cc.csrc.sparse.all.ops4d import Point2Voxel as Point2VoxelGPU4d
      

    3. 编译安装OpenPCDet

    cd OpenPCDet/
    python setup.py develop
    

准备数据集

  1. 下载kitti数据集,请自行前往Kitti官网下载3D检测数据集
  2. 下载训练数据集data目录
    1. 克隆OpenPCDet源码:git clone https://github.com/open-mmlab/OpenPCDet.git
    2. 将OpenPCDet源码的data目录复制到本仓的OpenPCDet工程目录下
  3. 解压下载的kitti数据集,并按照如下方式组织
    OpenPCDet
    ├── data
    │   ├── kitti
    │   │   │── ImageSets
    │   │   │── training
    │   │   │   ├──calib & velodyne & label_2 & image_2 & (optional: planes) & (optional: depth_2)
    │   │   │── testing
    │   │   │   ├──calib & velodyne & image_2
    ├── pcdet
    ├── tools
    
  4. 修改tools/cfgs/kitti_models/pointpillar.yamlUSE_ROAD_PLANE: False
  5. 序列化数据集生成数据信息
    cd OpenPCDet/
    python -m pcdet.datasets.kitti.kitti_dataset create_kitti_infos tools/cfgs/dataset_configs/kitti_dataset.yaml
    

模型训练

  1. 进入OpenPCDet的根目录。
    cd OpenPCDet/
    
  2. 运行训练脚本。 该模型支持单机单机8卡训练
    cd tools/test
    bash train_pointpillar_full_8p.sh
    bash train_pointpillar_performance_8p.sh
    
    训练完成后,权重文件保存在当前路径下,并输出模型训练精度和性能信息

训练结果对比

精度

训练精度结果展示表

Exp mAP_bbox mAP_3d mAP_bev mAP_aos
8p-竞品A 80.19 76.58 79.27 73.58
8p-Atlas 800T A2 80.93 76.67 79.52 74.91

性能

训练性能结果展示表

Exp FPS
8p-竞品A 51
8p-Atlas 800T A2 47

FAQ

ImportError:/usr/local/gcc-7.5.0/lib64/libgomp.so.1:cannot allocate memory in static TLS block,

glibc版本兼容性问题,升级glibc版本或者手动导入环境变量export LD_PRELOAD=/usr/local/gcc-7.5.0/lib64/libgomp.so.1

ImportError: {conda_env_path}/bin/../lib/libgomp.so.1:cannot allocate memory in static TLS block

出现上述报错时,将报错路径补充到环境变量LD_PRELOAD中即可,可参考以下指令

export LD_PRELOAD={conda_env_path}/bin/../lib/libgomp.so.1:$LD_PRELOAD # {conda_env_path}替换为实际使用python环境根目录

ImportError: {conda_env_path}/lib/python3.8/site-packages/sklearn/__check_build/../../scikit_learn.libs/libgomp-d22c30c5.so.1.0.0

出现上述报错时,将报错路径补充到环境变量LD_PRELOAD中即可,可参考以下指令

export LD_PRELOAD={conda_env_path}/lib/python3.8/site-packages/sklearn/__check_build/../../scikit_learn.libs/libgomp-d22c30c5.so.1.0.0:$LD_PRELOAD # {conda_env_path}替换为实际使用python环境根目录

ImportError: libblas.so.3: cannot open shared object file: No such file or directory

执行以下指令安装相关依赖即可

conda install -c conda-forge blas

数据预处理序列化时报错

可能时网络不稳定导致数据集下载时缺失部分image或者.bin文件

报错:KeyError:'road_plane'

修改tools/cfgs/kitti_models/pointpillar.yamlUSE_ROAD_PLANE: False

安装编译cumm时报错:TypeError: ccimport() got multiple values for argument 'std'

pip install ccimport==0.3.7

训练卡住,日志记录Wait 30 seconds for next check

需要删除上次训练的存储,位置在OpenPCDet/output/kitti_models/pointpillat/default

运行报错:bc: command not found

bc命令是linux系统上的任意精度计算器语言, 有上述提示说明操作系统尚未安装bc,执行以下命令安装bc

yum -y install bc

pkg_resources.DistributionNotFound: The 'protobuf' distribution was not found and is required by the application

执行以下指令在python环境中安装protobuf三方依赖

pip install protobuf

版本说明

[2024-01-24] NEW: PointPillar模型在NPU设备首次适配.

公网地址说明

代码涉及公网地址及个人邮箱地址参考 ./public_address_statement.md