-
Notifications
You must be signed in to change notification settings - Fork 0
/
exps_tianshou_behavior.py
206 lines (194 loc) · 6.04 KB
/
exps_tianshou_behavior.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
from doexp import cmd, In, Out, GLOBAL_CONTEXT
from socket import gethostname
from subprocess import run
import math
import os
HOST = gethostname()
WANDB_ENTITY = ""
if "WANDB_ENTITY" in os.environ:
WANDB_ENTITY = os.environ["WANDB_ENTITY"]
else:
print("Please set WANDB_ENTITY")
os.environ["WANDB__SERVICE_WAIT"] = "300"
SLURM_HOSTNAME = "brain.usc.edu"
if HOST == SLURM_HOSTNAME:
# MIN_CONCURRENT_JOBS = 100
MIN_CONCURRENT_JOBS = 50
# MIN_CONCURRENT_JOBS = 30
GLOBAL_CONTEXT.max_core_alloc = 600
squeue_res = run(["squeue", "--all"], check=False, capture_output=True)
if squeue_res.returncode == 0:
out = squeue_res.stdout.decode()
waiting_job_count = 0
for line in out.split("\n"):
if "(Priority)" in line or "(Resources)" in line:
# if "slurm-lon" not in line:
# waiting_job_count += 1
# if " kr " in line:
waiting_job_count += 1
if waiting_job_count <= 1:
# Presumably free resources on the cluster
GLOBAL_CONTEXT.max_concurrent_jobs += 1
else:
# print("waiting_job_count =", waiting_job_count)
if GLOBAL_CONTEXT.max_concurrent_jobs > len(GLOBAL_CONTEXT.running):
print(f"Running {len(GLOBAL_CONTEXT.running)} jobs")
# Someone is waiting (maybe us), don't start any more jobs
# GLOBAL_CONTEXT.max_concurrent_jobs = len(GLOBAL_CONTEXT.running) - 1
GLOBAL_CONTEXT.max_concurrent_jobs = MIN_CONCURRENT_JOBS
if GLOBAL_CONTEXT.max_concurrent_jobs < MIN_CONCURRENT_JOBS:
GLOBAL_CONTEXT.max_concurrent_jobs = MIN_CONCURRENT_JOBS
# MAX_CONCURRENT_JOBS = 300
MAX_CONCURRENT_JOBS = 170
# MAX_CONCURRENT_JOBS = 2
if GLOBAL_CONTEXT.max_concurrent_jobs > MAX_CONCURRENT_JOBS:
GLOBAL_CONTEXT.max_concurrent_jobs = MAX_CONCURRENT_JOBS
# print(f"Running {len(GLOBAL_CONTEXT.running)} jobs")
seeds = list(range(10))
mujoco_env_names_v3 = [
"HalfCheetah-v3",
"Walker2d-v3",
"Hopper-v3",
"Swimmer-v3",
"InvertedPendulum-v2",
"InvertedDoublePendulum-v2",
"Reacher-v2",
]
EPOCHS = 500 # Basically, this determines the x-axis plot resolution for Tianshou logs
MT50_ENV_NAMES = [
"assembly",
"basketball",
"bin-picking",
"box-close",
"button-press-topdown",
"button-press-topdown-wall",
"button-press",
"button-press-wall",
"coffee-button",
"coffee-pull",
"coffee-push",
"dial-turn",
"disassemble",
"door-close",
"door-lock",
"door-open",
"door-unlock",
"hand-insert",
"drawer-close",
"drawer-open",
"faucet-open",
"faucet-close",
"hammer",
"handle-press-side",
"handle-press",
"handle-pull-side",
"handle-pull",
"lever-pull",
"peg-insert-side",
"pick-place-wall",
"pick-out-of-hole",
"reach",
"push-back",
"push",
"pick-place",
"plate-slide",
"plate-slide-side",
"plate-slide-back",
"plate-slide-back-side",
"peg-unplug-side",
"soccer",
"stick-push",
"stick-pull",
"push-wall",
"reach-wall",
"shelf-place",
"sweep-into",
"sweep",
"window-open",
"window-close",
]
MT10_ENV_NAMES = [
'reach',
'push',
'pick-place',
'door-open',
'drawer-open',
'drawer-close',
'button-press-topdown',
'peg-insert-side',
'window-open',
'window-close',
]
for seed in seeds:
if seed < 3:
base_priority = 60
else:
base_priority = 40
for env_i, env in enumerate(MT50_ENV_NAMES):
group = "fixpo-tianshou-metaworld-behavior"
cmd(
"python",
"src/metaworld_fixpo_debug_tianshou.py",
"--seed",
seed,
"--env",
env,
"--epoch", 100,
"--wandb-entity", WANDB_ENTITY,
"--wandb-group", group,
"--gen-behavior", 1,
"--log-dir",
Out(f"fixpo_tianshou/env={env}_seed={seed}_group={group}/"),
warmup_time=1,
ram_gb=6,
priority=(base_priority, -seed, -env_i),
cores=2,
)
for env_i, env in enumerate(MT10_ENV_NAMES):
if env == 'pick-place':
env_priority = 10
else:
env_priority = 0
for base_env in MT10_ENV_NAMES:
group = "fixpo-tianshou-metaworld-transfer-behavior"
cmd(
"python",
"src/metaworld_fixpo_debug_tianshou.py",
"--seed",
seed,
"--env",
env,
"--epoch", 200,
"--base-task-path", In(f"fixpo_tianshou/env={base_env}_seed={seed}_group=fixpo-tianshou-metaworld-behavior/policy.pth"),
"--wandb-entity", WANDB_ENTITY,
"--wandb-group", group,
"--gen-behavior", 1,
"--log-dir",
Out(f"fixpo_tianshou/env={env}_base-env={base_env}_seed={seed}_group={group}/"),
warmup_time=1,
ram_gb=6,
priority=(base_priority - 5, env_priority, -seed, -env_i),
cores=2,
)
# back_group = "fixpo-tianshou-metaworld-transfer-back-behavior"
# cmd(
# "python",
# "src/metaworld_fixpo_debug_tianshou.py",
# "--seed",
# seed,
# "--env",
# "pick-place",
# "--epoch", 100,
# "--base-task-path", In(f"fixpo_tianshou/env={env}_seed={seed}_group={group}/policy.pth"),
# "--wandb-entity", WANDB_ENTITY,
# "--wandb-group", group,
# "--gen-behavior", 1,
# "--log-dir",
# Out(
# f"fixpo_tianshou/env=pick-place_base_env={env}_seed={seed}_group={back_group}/"
# ),
# warmup_time=1,
# ram_gb=6,
# priority=(base_priority + 10, -seed, -env_i),
# cores=2,
# )