-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathlaunch.py
110 lines (98 loc) · 2.79 KB
/
launch.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import os
import datetime
import argparse
DEFAULT_ADDR = "127.0.1.1"
DEFAULT_PORT = "8338"
CMD_RL = "export CUDA_LAUNCH_BLOCKING=1 && \
export PYTHONPATH={}:$PYTHONPATH && \
python -u -m torch.distributed.launch \
--nproc_per_node={} \
--master_addr {} \
--master_port {} \
--use_env \
{} \
--task-type {} \
--noise {} \
--exp-config {} \
--run-type {} \
--n-gpu {} \
--cur-time {}"
CMD_VO = "export CUDA_LAUNCH_BLOCKING=1 && \
export PYTHONPATH={}:$PYTHONPATH && \
python {} \
--task-type {} \
--noise {} \
--exp-config {} \
--run-type {} \
--n-gpu {} \
--cur-time {}"
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--task-type",
choices=["rl", "vo"],
required=True,
help="Specify the category of the task",
)
parser.add_argument(
"--noise",
type=int,
required=True,
help="Whether adding noise into environment",
)
parser.add_argument(
"--run-type",
choices=["train", "eval"],
required=True,
help="run type of the experiment (train or eval)",
)
parser.add_argument(
"--repo-path", type=str, required=True, help="path to PointNav repo",
)
parser.add_argument(
"--n_gpus", type=int, required=True, help="path to PointNav repo",
)
parser.add_argument(
"--addr", type=str, required=True, help="master address",
)
parser.add_argument(
"--port", type=str, required=True, help="master port",
)
args = parser.parse_args()
cur_time = datetime.datetime.now().strftime("%Y%m%d_%H%M%S%f")
if args.task_type == "rl":
cur_config_f = os.path.join(args.repo_path, "configs/rl/ddppo_pointnav.yaml")
elif args.task_type == "vo":
cur_config_f = os.path.join(args.repo_path, "configs/vo/vo_pointnav.yaml")
else:
pass
if "rl" in args.task_type:
tmp_cmd = CMD_RL.format(
args.repo_path,
args.n_gpus,
args.addr,
args.port,
# {}/point_nav/run.py
os.path.join(args.repo_path, "pointnav_vo/run.py"),
args.task_type,
args.noise,
cur_config_f,
args.run_type,
args.n_gpus,
cur_time,
)
elif "vo" in args.task_type:
tmp_cmd = CMD_VO.format(
args.repo_path,
os.path.join(args.repo_path, "pointnav_vo/run.py"),
args.task_type,
args.noise,
cur_config_f,
args.run_type,
args.n_gpus,
cur_time,
)
else:
raise ValueError
print("\n", tmp_cmd, "\n")
os.system(tmp_cmd)