3D目标检测算法配置--CIA-SSD与spconv1.2的安装
3D目标检测算法配置–CIA-SSD与spconv1.2的安装
MiniConda
要是安装过anaconda的话就可以跳过这一步,注意不要将conda加到环境变量里面,要不然可能会有意想不到的报错,很麻烦
wget -c https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh chmod +x Miniconda3-latest-Linux-x86_64.sh bash Miniconda3-latest-Linux-x86_64.sh# 记住更新PATH到~/.bashrc时选no
没有加入环境变量时启动conda可以用该命令
source <path_to_your_conda_installation>/bin/activate# 默认进入base source <path_to_your_conda_installation>/bin/activate <your_env_name># 进入指定环境
spconv1.2的安装
conda create --name CIA-SSD python=3.8 pytorch=1.4 torchvision=0.5 cudatoolkit=10.1 cudatoolkit-dev=10.1 cmake --channel pytorch conda activate CIA-SSD conda install cudnn conda install boost git clone https://github.com/traveller59/spconv.git --recursive#要是加载超时可以把第一个https换成git
使用which nvcc#查看cuda路径
在CMakeList.txt中添加以下cuda路径,添加在第五行,添加完如下图所示。(或者在setup.py的cmake_args中添加’-DCMAKE_CUDA_COMPILER=/home/detection/local/miniconda3/envs/CIA-SSD/bin/nvcc’)
接下来将~/miniconda3/envs/CIA-SSD/lib/python3.8/site-packages/torch/share/cmake/Caffe2/Caffe2Targets.cmake这个文件中usr相关的依赖项全部改成自己路径下的,然后重新运行应该就可以了。
在spconv文件夹下进行编译运行
python setup.py bdist_wheel cd dist/ pip install *
如果报错error: ‘RegisterOperators’ is not a member of ‘torch’,将对应文件所在行的中的torch::RegisterOperators改为torch::jit::RegisterOperators即可。
代码位置spconv/src/spconv/all.cc,line20
/* 这个是原版 */ static auto registry = torch::jit::RegisterOperators("spconv::get_indice_pairs_2d", &spconv::getIndicePair<2>) .op("spconv::get_indice_pairs_3d", &spconv::getIndicePair<3>) /* 由于torch版本更新命名空间,需要把jit删掉,如下 */ static auto registry = torch::RegisterOperators("spconv::get_indice_pairs_2d", &spconv::getIndicePair<2>) .op("spconv::get_indice_pairs_3d", &spconv::getIndicePair<3>)
Det3D的安装
在安装Det3D过程中可能出现一片红的报错,不要慌,先等他运行完,看看能不能用,不能用再找问题解决
git clone https://github.com/poodarchu/Det3D.git#要是连接超时可以参考上面 cd Det3D python setup.py build develop
CIA-SSD的安装
安装CIA-SSD的时候缺少fire库,yaml库,requests库。可以选择在安装CIA-SSD前安装这些库,也可以先运行代码,出现报错之后再解决
pip install fire#安装fire库 pip install pyyaml#安装fire库,注意包名是pyyaml不是yaml pip install requests#安装requests库 python ./CIA-SSD/tools/create_data.py#安装CIA-SSD
要是出现ModuleNotFoundError: No module named ‘det3d.ops.nms.nms’ 解决方法就是再次进入Det3D重新编译
cd Det3D python setup.py build develop
这种情况,根据报错的路径(比如错误路径为/home/detection/CIA-SSD/tools/create_data.py line11)进入查看可发现报错为路径错误
原代码为
将代码中的相对路径改成绝对路径,比如如下图
然后重新运行
python ./CIA-SSD/tools/create_data.py