代码复现 :SECOND pytorch版本 ②

为了防止忘记。。。。
配置环境太麻烦了。。。。头疼。。。。

环境:

运行系统:Ubuntu18.04
使用语言:Python3.6
硬件支持:GTX2080Ti + CUDA10.0+CUDNN7.6.5 + PyTorch 1.4.0 + Cmake3.10.2

克隆second.pytorch代码

git clone https://github.com/traveller59/second.pytorch
cd  ./second.pytorch/second

安装spconv

1 克隆spconv代码(在second.pytorch文件夹下)

git clone https://github.com/traveller59/spconv  --recursive

2 编译spconv代码

cd spconv
python  setup.py  bdist_wheel

我的结果如下:

running bdist_wheel
running build
running build_py
running build_ext
Release
|||||CMAKE ARGS||||| ['-DCMAKE_PREFIX_PATH=/home/cv/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch', '-DPYBIND11_PYTHON_VERSION=3.6', '-DSPCONV_BuildTests=OFF', '-DPYTORCH_VERSION=10400', '-DCMAKE_CUDA_FLAGS="--expt-relaxed-constexpr" -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/cv/PycharmProjects/SECOND_pytorch/second/spconv/build/lib.linux-x86_64-3.6/spconv', '-DCMAKE_BUILD_TYPE=Release']
-- Caffe2: CUDA detected: 10.0
-- Caffe2: CUDA nvcc is: /usr/local/cuda/bin/nvcc
-- Caffe2: CUDA toolkit directory: /usr/local/cuda
-- Caffe2: Header version is: 10.0
-- Found CUDNN: /usr/local/cuda/lib64/libcudnn.so  
-- Found cuDNN: v7.5.0  (include: /usr/local/cuda/include, library: /usr/local/cuda/lib64/libcudnn.so)
-- Autodetected CUDA architecture(s):  7.5
-- Added CUDA NVCC flags for: -gencode;arch=compute_75,code=sm_75
-- Found torch: /home/cv/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/lib/libtorch.so  
-- Autodetected CUDA architecture(s):  7.5
-- Found PythonInterp: /home/cv/anaconda3/envs/pytorch/bin/python3.6 (found suitable version "3.6.12", minimum required is "3.6") 
-- Found PythonLibs: /home/cv/anaconda3/envs/pytorch/lib/libpython3.6m.so
-- Performing Test HAS_CPP14_FLAG
-- Performing Test HAS_CPP14_FLAG - Success
-- pybind11 v2.5.0
-- Found OpenMP_CXX: -fopenmp (found version "4.5") 
-- Found OpenMP: TRUE (found version "4.5")  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cv/PycharmProjects/SECOND_pytorch/second/spconv/build/temp.linux-x86_64-3.6
Scanning dependencies of target spconv_nms
Scanning dependencies of target cuhash
[  4%] Building CUDA object src/utils/CMakeFiles/spconv_nms.dir/nms.cu.o
[  8%] Building CUDA object src/cuhash/CMakeFiles/cuhash.dir/hash_functions.cu.o
[ 12%] Building CUDA object src/cuhash/CMakeFiles/cuhash.dir/hash_table.cu.o
。。。

在这里插入图片描述

(注意:如果这一步出错了,说明pytorch与pytorchvision版本匹配有问题)

3 安装spconv

cd  ./dist   
pip  install spconv-1.1-cp36-cp36m-linux_x86_64.whl

在这里插入图片描述
至此,spconv编译到此结束了。

安装Apex

输入以下命令一次性安装成功

git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./

在这里插入图片描述

如果出现括号内错误(apex Error : Given no hashes to check 137 links for project ‘pip’: discarding no candidates)请使用下面的命令进行安装。

git clone https://www.github.com/nvidia/apex
cd apex
python setup.py install

添加second.pytorch环境变量

export  PYTHONPATH=$PYTHONPATH:/your_second.pytorch_path/ 

至此,关于second.pytorch在second虚拟环境下面的环境依赖安装结束。

代码运行

1、 下载数据

  • Velodyne point clouds (29 GB): unzip it and put ‘training’ and
    ‘testing’ sub-folders into ‘data/KITTI/point_cloud’
  • Training labels of object data set (5 MB) for input labels of
    VoxelNet: unzip it and put ‘training’ sub-folder into ‘data/KITTI/label’
  • Camera calibration matrices of object data set (16 MB) for
    visualization of predictions: unzip it and put ‘training’ and ‘testing’ sub-folders into ‘data/KITTI/calib’
  • Left color images of object data set (12 GB) for visualization of
    predictions: unzip it and put ‘training’ and ‘testing’ sub-folders
    into ‘data/KITTI/image’

2、准备数据格式

3、运行数据生成命令

1.5.1版本做如下操作

###创建kitti infos
python create_data.py create_kitti_info_file --data_path=data/KITTI_DATASET_ROOT
###创建reduced point cloud
python create_data.py create_reduced_point_cloud --data_path=data/KITTI_DATASET_ROOT
###创建groundtruth数据库信息
python create_data.py create_groundtruth_database --data_path=data/KITTI_DATASET_ROOT

1.6版本做如下操作(我们使用的)

python create_data.py kitti_data_prep --root_path=data/KITTI_DATASET_ROOT

在这里插入图片描述

4、修改参数配置

second.pytorch/second/ 下面有个configs文件夹,里面有每个训练参数文件的配置。以car.fhd.config为例,打开文件找到对应上面的部分,进行数据路径配置,修改成自己的数据路径即可。

5、运行训练命令

python ./pytorch/train.py train --config_path=./configs/car.fhd.config --model_dir=/path/to/model_dir

(注意:这里使用的是单GPU训练,这里的/path/to路径可以设置为KITTI_DATASET_ROOT的路径)

6、运行评估命令

python ./pytorch/train.py evaluate --config_path=./configs/car.fhd.config --model_dir=/path/to/model_dir --measure_time=True --batch_size=1

(注意:这里使用的是单GPU评估,这里的/path/to路径可以设置为KITTI_DATASET_ROOT的路径)

参考(感谢)
https://blog.csdn.net/r1141207831/article/details/103756292(膜拜)
https://blog.csdn.net/qq_35632833/article/details/106843842
https://blog.csdn.net/Left_control_right/article/details/109225993?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_title-10&spm=1001.2101.3001.4242
https://blog.csdn.net/Doraemon_Zzn/article/details/103757625?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control
https://cloud.tencent.com/developer/article/1629517
https://blog.csdn.net/Left_control_right/article/details/109161641
https://blog.csdn.net/Small_Munich/article/details/99053921
https://blog.csdn.net/qinlele1994/article/details/110958064

累了,毁灭吧、、、、、、

  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值