端到端激光雷达全局定位RING#配置流程
关于端到端激光雷达全局定位RING#配置流程
- 端到端激光雷达全局定位RING#配置流程
- 前言
- 环境准备
- 克隆代码库并安装配置
- 解决安装过程中的常见问题
- 从源码安装外部依赖项
- 完成安装
- 总结
- 补充
- error6 No module named 'torch_radon_cuda'
- error7 ImportError: cannot import name 'Radon' from 'torch_radon' cannot import name 'RadonFanbeam' from 'torch_radon'
- error8 ModuleNotFoundError: No module named 'efficientnet_pytorch'
- Error9 NameError: name 'OxfordConfig' is not defined
- Error9 ModuleNotFoundError: No module named 'pcdet'
- Error10 ModuleNotFoundError: No module named 'av2'
前言
RING#终于开源了!作为一款端到端激光雷达全局定位系统,我迫不及待地想测试一下它的效果。本文将详细记录RING#的配置流程以及遇到的问题和解决方案,希望能帮助到同样对此感兴趣的朋友们。
环境准备
首先,我们需要创建一个独立的Python环境来避免依赖冲突:
conda create -n ringsharp python=3.8
conda activate ringsharp
克隆代码库并安装配置
接下来,我们克隆RING#的代码库并安装必要的依赖:
git clone https://github.com/lus6-Jenny/RINGSharp.git
cd RINGSharp
pip install -r requirements.txt
解决安装过程中的常见问题
在安装过程中,我遇到了几个问题,以下是问题详情及解决方案:
Error 01: 找不到torch模块
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [6 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-qu8n2f1w/mmdet3d_a0c07c2eb835450dbd01e59004e38414/setup.py", line 9, in <module>
import torch
ModuleNotFoundError: No module named 'torch'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
解决方案:
需要先安装PyTorch,可以参考RING++安装流程
pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113
Error 02: packaging包导入问题
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [8 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-1k6pl7wl/mmdet3d_3bec1b3b2bfb4b759e5e82df5910af7e/setup.py", line 10, in <module>
from torch.utils.cpp_extension import (BuildExtension, CppExtension,
File "/home/beabbit/anaconda3/envs/ringsharp/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 23, in <module>
from pkg_resources import packaging # type: ignore[attr-defined]
ImportError: cannot import name 'packaging' from 'pkg_resources' (/home/beabbit/anaconda3/envs/ringsharp/lib/python3.8/site-packages/pkg_resources/__init__.py)
[end of output]
解决方案:
更新pip、setuptools和packaging包:
pip install --upgrade pip setuptools packaging
从源码安装外部依赖项
有些组件需要手动编译,例如fast_gicp和torch-radon:
git clone https://github.com/SMRT-AIST/fast_gicp.git --recursive
cd fast_gicp
python setup.py install --user
Error 03: 找不到pybind11模块
编译过程中出现如下错误:
-- Found PCL: pcl_common;pcl_kdtree;pcl_octree;pcl_search;pcl_sample_consensus;pcl_filters;pcl_io;pcl_features;pcl_ml;pcl_segmentation;pcl_visualization;pcl_surface;pcl_registration;pcl_keypoints;pcl_tracking;pcl_recognition;pcl_stereo;pcl_apps;pcl_outofcore;pcl_people;/usr/lib/x86_64-linux-gnu/libboost_system.so;/usr/lib/x86_64-linux-gnu/libboost_filesystem.so;/usr/lib/x86_64-linux-gnu/libboost_date_time.so;/usr/lib/x86_64-linux-gnu/libboost_iostreams.so;/usr/lib/x86_64-linux-gnu/libboost_regex.so;optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so;/usr/lib/libOpenNI.so;/usr/lib/libOpenNI2.so;vtkChartsCore;vtkCommonColor;vtkCommonCore;vtksys;vtkCommonDataModel;vtkCommonMath;vtkCommonMisc;vtkCommonSystem;vtkCommonTransforms;vtkCommonExecutionModel;vtkFiltersGeneral;vtkCommonComputationalGeometry;vtkFiltersCore;vtkInfovisCore;vtkFiltersExtraction;vtkFiltersStatistics;vtkImagingFourier;vtkImagingCore;vtkalglib;vtkRenderingContext2D;vtkRenderingCore;vtkFiltersGeometry;vtkFiltersSources;vtkRenderingFreeType;/usr/lib/x86_64-linux-gnu/libfreetype.so;/usr/lib/x86_64-linux-gnu/libz.so;vtkFiltersModeling;vtkImagingSources;vtkInteractionStyle;vtkInteractionWidgets;vtkFiltersHybrid;vtkImagingColor;vtkImagingGeneral;vtkImagingHybrid;vtkIOImage;vtkDICOMParser;vtkmetaio;/usr/lib/x86_64-linux-gnu/libjpeg.so;/usr/lib/x86_64-linux-gnu/libpng.so;/usr/lib/x86_64-linux-gnu/libtiff.so;vtkRenderingAnnotation;vtkRenderingVolume;vtkIOXML;vtkIOCore;vtkIOXMLParser;/usr/lib/x86_64-linux-gnu/libexpat.so;vtkIOGeometry;vtkIOLegacy;vtkIOPLY;vtkRenderingLOD;vtkViewsContext2D;vtkViewsCore;vtkRenderingContextOpenGL2;vtkRenderingOpenGL2;FLANN::FLANN
-- Found OpenMP_C: -fopenmp (found version "4.5")
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
-- Could NOT find pybind11 (missing: pybind11_DIR)
CMake Error at CMakeLists.txt:95 (pybind11_add_module):
Unknown CMake command "pybind11_add_module".
解决方案:
安装pybind11库:
sudo apt install python3-pybind11
接下来安装torch-radon:
git clone https://github.com/matteo-ronchetti/torch-radon.git -b v2
cd torch-radon
python setup.py install
Error 04: dim3类型定义缺失
安装torch-radon时遇到以下错误:
In file included from ./include/symbolic.h:5,
from src/symbolic.cpp:1:
./include/parameter_classes.h:98:5: error: 'dim3' does not name a type
98 | dim3 get_block_dim() const;
| ^~~~
./include/parameter_classes.h:100:5: error: 'dim3' does not name a type
100 | dim3 get_grid_size(int x, int y = 1, int z = 1) const;
| ^~~~
ERROR IN COMPILATION
解决方案:
打开./include/parameter_classes.h
文件,修改如下:
#pragma once
#include <string>
#include "defines.h"
#include "vectors.h"
struct dim3; //增加这一行声明
Error 05: error: Could not find suitable distribution for Requirement.parse(‘alpha-transform’)
Download error on https://pypi.org/simple/: [Errno 104] Connection reset by peer -- Some packages may not be found!
No local packages or working download links found for alpha-transform
error: Could not find suitable distribution for Requirement.parse('alpha-transform')
解决方案
pip install alpha-transform -i https://pypi.tuna.tsinghua.edu.cn/simple
完成安装
最后,完成RING#的安装:
cd glnet/ops
python setup.py develop
cd ../..
python setup.py develop
至此,RING#的安装配置全部完成!
总结
尽管在安装过程中遇到了一些问题,但通过逐步排查和解决,我们成功完成了RING#的配置。这个端到端激光雷达全局定位系统拥有巨大的潜力,非常期待它在实际应用中的表现。
补充
这里记录后续遇到的一些问题
error6 No module named ‘torch_radon_cuda’
Traceback (most recent call last):
File "train.py", line 6, in <module>
from trainer import do_train
File "/home/beabbit/study_space/RINGSharp/tools/trainer.py", line 13, in <module>
from glnet.models.model_factory import model_factory
File "/home/beabbit/study_space/RINGSharp/glnet/models/model_factory.py", line 7, in <module>
from ..models.localizer.ring_sharp_v import RINGSharpV
File "/home/beabbit/study_space/RINGSharp/glnet/models/localizer/ring_sharp_v.py", line 9, in <module>
from torch_radon import Radon, ParallelBeam, RadonFanbeam
File "/home/beabbit/anaconda3/envs/ringsharp/lib/python3.8/site-packages/torch_radon-2.0.0-py3.8-linux-x86_64.egg/torch_radon/__init__.py", line 3, in <module>
from .volumes import Volume2D, Volume3D
File "/home/beabbit/anaconda3/envs/ringsharp/lib/python3.8/site-packages/torch_radon-2.0.0-py3.8-linux-x86_64.egg/torch_radon/volumes.py", line 2, in <module>
from .cuda_backend import VolumeCfg
File "/home/beabbit/anaconda3/envs/ringsharp/lib/python3.8/site-packages/torch_radon-2.0.0-py3.8-linux-x86_64.egg/torch_radon/cuda_backend.py", line 12, in <module>
from torch_radon_cuda import *
ModuleNotFoundError: No module named 'torch_radon_cuda'
解决方案:
在./torch_radon/setup.py line28-34取消注释
ext_modules=[
CUDAExtension('torch_radon_cuda', [os.path.abspath('src/pytorch.cpp')],
include_dirs=[os.path.abspath('include')],
library_dirs=[os.path.abspath("objs")],
libraries=["m", "c", "gcc", "stdc++", "cufft", "torchradon"],
# strip debug symbols
extra_link_args=["-Wl,--strip-all"]
),
Pybind11Extension("tr", [os.path.abspath("src/python.cpp")], include_dirs=[os.path.abspath('include')],
library_dirs=[os.path.abspath("objs")],
libraries=["torchradon"],
# strip debug symbols
extra_link_args=["-Wl,--strip-all"], cxx_std=14)
],
error7 ImportError: cannot import name ‘Radon’ from ‘torch_radon’ cannot import name ‘RadonFanbeam’ from ‘torch_radon’
Traceback (most recent call last):
File "train.py", line 6, in <module>
from trainer import do_train
File "/home/beabbit/study_space/RINGSharp/tools/trainer.py", line 13, in <module>
from glnet.models.model_factory import model_factory
File "/home/beabbit/study_space/RINGSharp/glnet/models/model_factory.py", line 7, in <module>
from ..models.localizer.ring_sharp_v import RINGSharpV
File "/home/beabbit/study_space/RINGSharp/glnet/models/localizer/ring_sharp_v.py", line 9, in <module>
from torch_radon import Radon, ParallelBeam, RadonFanbeam
ImportError: cannot import name 'Radon' from 'torch_radon' (/home/beabbit/anaconda3/envs/ringsharp/lib/python3.8/site-packages/torch_radon-2.0.0-py3.8-linux-x86_64.egg/torch_radon/__init__.py)
解决方案,删掉所有的Radon和RadonFanbeam,主要原因是torch_radonv2已经不包括这些类了
error8 ModuleNotFoundError: No module named ‘efficientnet_pytorch’
Traceback (most recent call last):
File "train.py", line 6, in <module>
from trainer import do_train
File "/home/beabbit/study_space/RINGSharp/tools/trainer.py", line 13, in <module>
from glnet.models.model_factory import model_factory
File "/home/beabbit/study_space/RINGSharp/glnet/models/model_factory.py", line 8, in <module>
from glnet.models.localizer.vdisco import vDiSCO
File "/home/beabbit/study_space/RINGSharp/glnet/models/localizer/vdisco.py", line 12, in <module>
from glnet.models.attention.attentions import SpatialCrossAttention, VanillaSelfAttention
File "/home/beabbit/study_space/RINGSharp/glnet/models/attention/attentions.py", line 9, in <module>
from efficientnet_pytorch import EfficientNet
ModuleNotFoundError: No module named 'efficientnet_pytorch'
还是装
pip install efficientnet-pytorch -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple some-package
Error9 NameError: name ‘OxfordConfig’ is not defined
Traceback (most recent call last):
File "train.py", line 6, in <module>
from trainer import do_train
File "/home/beabbit/study_space/RINGSharp/tools/trainer.py", line 13, in <module>
from glnet.models.model_factory import model_factory
File "/home/beabbit/study_space/RINGSharp/glnet/models/model_factory.py", line 15, in <module>
from glnet.models.localizer.ring_sharp_l import RINGSharpL
File "/home/beabbit/study_space/RINGSharp/glnet/models/localizer/ring_sharp_l.py", line 26, in <module>
class RINGSharpL(nn.Module):
File "/home/beabbit/study_space/RINGSharp/glnet/models/localizer/ring_sharp_l.py", line 27, in RINGSharpL
def __init__(self, model_params: ModelParams, config=OxfordConfig()):
NameError: name 'OxfordConfig' is not defined
Error9 ModuleNotFoundError: No module named ‘pcdet’
Traceback (most recent call last):
File "train.py", line 6, in <module>
from trainer import do_train
File "/home/beabbit/study_space/RINGSharp/tools/trainer.py", line 13, in <module>
from glnet.models.model_factory import model_factory
File "/home/beabbit/study_space/RINGSharp/glnet/models/model_factory.py", line 17, in <module>
from glnet.models.localizer.lcdnet import LCDNet
File "/home/beabbit/study_space/RINGSharp/glnet/models/localizer/lcdnet.py", line 7, in <module>
from pcdet.config import cfg_from_yaml_file
ModuleNotFoundError: No module named 'pcdet'
装一个openpcdet的库
# 克隆仓库
cd ~/study_space
git clone https://github.com/open-mmlab/OpenPCDet.git
cd OpenPCDet
# 安装依赖
pip install -r requirements.txt
# 安装 OpenPCDet
python setup.py develop
Error10 ModuleNotFoundError: No module named ‘av2’
Traceback (most recent call last):
File "train.py", line 6, in <module>
from trainer import do_train
File "/home/beabbit/study_space/RINGSharp/tools/trainer.py", line 13, in <module>
from glnet.models.model_factory import model_factory
File "/home/beabbit/study_space/RINGSharp/glnet/models/model_factory.py", line 17, in <module>
from glnet.models.localizer.lcdnet import LCDNet
File "/home/beabbit/study_space/RINGSharp/glnet/models/localizer/lcdnet.py", line 9, in <module>
from pcdet.datasets.kitti.kitti_dataset import KittiDataset
File "/home/beabbit/study_space/RINGSharp/OpenPCDet/pcdet/datasets/__init__.py", line 15, in <module>
from .argo2.argo2_dataset import Argo2Dataset
File "/home/beabbit/study_space/RINGSharp/OpenPCDet/pcdet/datasets/argo2/argo2_dataset.py", line 7, in <module>
from av2.utils.io import read_feather
ModuleNotFoundError: No module named 'av2'
解决方案:同样是装库问题
pip install av2==0.1.0 -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple some-package
如果你在安装过程中遇到了其他问题,欢迎在评论区留言交流!