cuda版本10.1
pytorch:
根据cuda版本选择pytorch版本:
1. 创建conda虚拟环境:
conda create -y --name mmcv python=3.8
conda activate mmcv
2. 安装依赖库:
pytorch
:
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=10.1 -c pytorch
mmcv
:
pip install -U openmim
mim install mmcv-full==1.4.0
mmdet
:
mim install mmdet==2.20.0
mpi4py
:
pip install mpi4py==3.0.3
pillow
:
pip install pillow==8.4.0
tqdm
:
pip install tqdm
torchpack
:
pip install torchpack
nuscenes-devkit
:
pip install nuscenes-devkit
安装Open MPI 4.0.4
:
- 官网下载openmpi-4.0.4.tar.gz
- 解压openmpi-4.0.4.tar.gz
cd openmpi-4.0.4
./configure --prefix=/usr/local CC=gcc CXX=g++ FC=gfortran
sudo make all install
- 查看是否安装成功
which mpirun
- 如果显示路径,如:
/usr/local/bin/mpirun
,则说明安装成功。
3. 安装BEVFusion
cd ../bevfusion
python setup.py develop
报错
:
nvcc fatal : Unsupported gpu architecture ‘compute_80’
ninja: build stopped: subcommand failed.
原因
:
我的显卡是RTX2060 算力是7.5,故不支持compute_80(算力8.0), compute_86(算力8.6)
解决办法
:
注释setup.py中的第24,25行,即:
#“-gencode=arch=compute_80,code=sm_80”,
#“-gencode=arch=compute_86,code=sm_86”,
重新执行:
python setup.py develop
Installed /home/zhkai/BEV/bevfusion
Processing dependencies for mmdet3d==0.0.0
Finished processing dependencies for mmdet3d==0.0.0
安装成功!
4.数据准备
参考:NuScenes Dataset for 3D Object Detection
cd ../mmdetection3d
python tools/create_data.py nuscenes --root-path ./data/nuscenes --out-dir ./data/nuscenes --extra-tag nuscenes
报错
:
ImportError: libcudart.so.10.2: cannot open shared object file: No such file or directory
原因
:mmcv1.6.2版本与cuda10.1不匹配
解决办法
:重装mmcv
mim install mmcv-full==1.6.0
重新执行:
python tools/create_data.py nuscenes --root-path ./data/nuscenes --out-dir ./data/nuscenes --extra-tag nuscenes
报错
:
======
Loading NuScenes tables for version v1.0-trainval...
23 category,
8 attribute,
4 visibility,
64386 instance,
12 sensor,
10200 calibrated_sensor,
2631083 ego_pose,
68 log,
850 scene,
34149 sample,
2631083 sample_data,
1166187 sample_annotation,
4 map,
Done loading in 37.483 seconds.
======
Reverse indexing ...
Done reverse indexing in 8.1 seconds.
======
total scene num: 850
exist scene num: 850
train scene: 700, val scene: 150
[>>>> ] 6743/34149, 14.6 task/s, elapsed: 461s, ETA: 1875sTraceback (most recent call last):File "tools/create_data.py", line 250, in <module>nuscenes_data_prep(File "tools/create_data.py", line 74, in nuscenes_data_prepnuscenes_converter.create_nuscenes_infos(
...
FileNotFoundError: file "./data/nuscenes/samples/LIDAR_TOP/n008-2018-07-27-12-07-38-0400__LIDAR_TOP__1532707811049131.pcd.bin" does not exist
原因
:我只下载了trainval01、trainval02的数据,不是完整的训练数据
修改代码
:
参考:https://blog.csdn.net/weixin_38362784/article/details/111397440
文件:
mmdetection3d/tools/data_converter/nuscenes_converter.py
第167行
函数:_fill_trainval_infos
# for sample in mmcv.track_iter_progress(nusc.sample):
for sample in mmcv.track_iter_progress(nusc.sample[0:6743]):
这里为什么是6743
?
这只是我自己的推测,因为从上一步的报错内容可知,nusc.sample
是索引到6743
的时候报错的。
重新执行:
python tools/create_data.py nuscenes --root-path ./data/nuscenes --out-dir ./data/nuscenes --extra-tag nuscenes
======
Loading NuScenes tables for version v1.0-trainval...
23 category,
8 attribute,
4 visibility,
64386 instance,
12 sensor,
10200 calibrated_sensor,
2631083 ego_pose,
68 log,
850 scene,
34149 sample,
2631083 sample_data,
1166187 sample_annotation,
4 map,
Done loading in 37.468 seconds.
======
Reverse indexing ...
Done reverse indexing in 8.4 seconds.
======
total scene num: 850
exist scene num: 850
train scene: 700, val scene: 150
[>>>>>>>>>>>>>>>>>>>>>>>>>>] 6743/6743, 14.6 task/s, elapsed: 461s, ETA: 0s
train sample: 5512, val sample: 1231
======
Loading NuScenes tables for version v1.0-trainval...
23 category,
8 attribute,
4 visibility,
64386 instance,
12 sensor,
10200 calibrated_sensor,
2631083 ego_pose,
68 log,
850 scene,
34149 sample,
2631083 sample_data,
1166187 sample_annotation,
4 map,
Done loading in 39.969 seconds.
======
Reverse indexing ...
Done reverse indexing in 8.4 seconds.
======
[>>>>>>>>>>>>>>>>>>>>>>>>>>] 5512/5512, 4.8 task/s, elapsed: 1149s, ETA: 0s
======
Loading NuScenes tables for version v1.0-trainval...
23 category,
8 attribute,
4 visibility,
64386 instance,
12 sensor,
10200 calibrated_sensor,
2631083 ego_pose,
68 log,
850 scene,
34149 sample,
2631083 sample_data,
1166187 sample_annotation,
4 map,
Done loading in 41.562 seconds.
======
Reverse indexing ...
Done reverse indexing in 8.1 seconds.
======
[>>>>>>>>>>>>>>>>>>>>>>>>>>>] 1231/1231, 4.2 task/s, elapsed: 292s, ETA: 0s
Create GT Database of NuScenesDataset
[>>>>>>>>>>>>>>>>>>>>>>>>>>>] 5512/5512, 5.9 task/s, elapsed: 934s, ETA: 0s
load 12323 truck database infos
load 30252 pedestrian database infos
load 58001 car database infos
load 535 movable_object.debris database infos
load 9545 traffic_cone database infos
load 2365 motorcycle database infos
load 252 static_object.bicycle_rack database infos
load 509 movable_object.pushable_pullable database infos
load 11 vehicle.emergency.ambulance database infos
load 2610 construction_vehicle database infos
load 4037 trailer database infos
load 20002 barrier database infos
load 1963 bicycle database infos
load 1713 bus database infos
load 84 vehicle.emergency.police database infos
load 43 human.pedestrian.stroller database infos
load 149 animal database infos
load 12 human.pedestrian.wheelchair database infos
load 9 human.pedestrian.personal_mobility database infos
======
Loading NuScenes tables for version v1.0-test...
23 category,
8 attribute,
4 visibility,
0 instance,
12 sensor,
1800 calibrated_sensor,
462901 ego_pose,
15 log,
150 scene,
6008 sample,
462901 sample_data,
0 sample_annotation,
4 map,
Done loading in 8.141 seconds.
======
Reverse indexing ...
Done reverse indexing in 1.0 seconds.
======
total scene num: 150
exist scene num: 150
test scene: 150
[>>>>>>>>>>>>>>>>>>>>>>>>>>] 6008/6008, 328.9 task/s, elapsed: 18s, ETA: 0s
test sample: 6008
======
Loading NuScenes tables for version v1.0-test...
23 category,
8 attribute,
4 visibility,
0 instance,
12 sensor,
1800 calibrated_sensor,
462901 ego_pose,
15 log,
150 scene,
6008 sample,
462901 sample_data,
0 sample_annotation,
4 map,
Done loading in 5.318 seconds.
======
Reverse indexing ...
Done reverse indexing in 0.9 seconds.
======
[>>>>>>>>>>>>>>>>>>>>>>>>>>>] 6008/6008, 9.9 task/s, elapsed: 609s, ETA: 0s
成功!
5. Evaluation
- 下载预训练模型
./tools/download_pretrained.sh
- Then, you will be able to run:
参考:https://github.com/mit-han-lab/bevfusion
如果是单颗GPU,那就得对tools/test.py
的做一定的修改:
#注释掉dist.init()
# dist.init()#修改torch.cuda.set_device
# torch.cuda.set_device(dist.local_rank())torch.cuda.set_device(0)#修改distributed
# distributed = Truedistributed = False
然后执行,例如:
python tools/test.py configs/nuscenes/seg/fusion-bev256d2-lss.yaml pretrained/bevfusion-seg.pth --eval map
6. Training
To be continued…