forked from HpWang-whu/RoReg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_preprocessing_global.py
53 lines (39 loc) · 1.79 KB
/
run_preprocessing_global.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os, shutil
from multiprocessing import Pool
from pathlib import Path
import numpy as np
PY3="python3"
GPU = "0"
os.environ["CUDA_VISIBLE_DEVICES"] = GPU
PREPROCESSING_DIR="/benchmark/experiments/RoReg/preprocessing/"
VOXEL_DIR = "/benchmark/experiments/RoReg/voxel/"
base_command = (f'{PY3}' + ' testset.py ')
# datasets = ['urban05', 'apartment', 'gazebo_summer', 'gazebo_winter', 'hauptgebaude', 'plain', 'stairs',
# 'wood_autumn', 'wood_summer', 'long_office_household', 'pioneer_slam', 'pioneer_slam3',
# 'box_met', 'p2at_met', 'planetary_map']
datasets = ['pioneer_slam3', 'box_met', 'p2at_met', 'planetary_map']
commands = []
for dataset in datasets:
problem_name = dataset + "_global"
f = os.path.join(VOXEL_DIR, problem_name+".npy")
voxel = np.load(f)
print(f'{problem_name} voxel size: {voxel}')
full_command = (base_command +
f' --voxel_size {voxel}'
f' --dataset {dataset}')
time_command = (f'command time --verbose -o {PREPROCESSING_DIR}/preprocessing_stats/{dataset}_time.txt '
+ full_command)
nvidia_command = (f'nvidia-smi --query-gpu=timestamp,memory.used -i 0 --format=csv -lms 1 > '
f'{PREPROCESSING_DIR}/preprocessing_stats/{dataset}_memory.txt')
full_command_stats = f'parallel -j2 -u --halt now,success=1 ::: \'{time_command}\' \'{nvidia_command}\''
commands.append(full_command_stats)
if not os.path.exists(PREPROCESSING_DIR):
os.makedirs(PREPROCESSING_DIR)
os.makedirs(PREPROCESSING_DIR+"/preprocessing_stats/")
# save config in result directory
txt_commands = os.path.join(PREPROCESSING_DIR, "readme.md")
with open(txt_commands, 'w') as f:
for item in commands:
f.write("%s\n" % item)
pool = Pool(1)
pool.map(os.system, commands)