-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_actor.py
56 lines (40 loc) · 993 Bytes
/
run_actor.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
from configuration import ALG
if ALG == "APE_X":
from APE_X.Player import Player
elif ALG == "R2D2":
from R2D2.Player import Player
elif ALG == "IMPALA":
from IMPALA.Player import Player
else:
raise RuntimeError("!!")
from argparse import ArgumentParser
import ray
parser = ArgumentParser()
parser.add_argument(
"--num-worker",
type=int,
default=2
)
parser.add_argument(
"--start-idx",
type=int,
default=0
)
if __name__ == "__main__":
# p = Player()
# p.run()
# -------------- Player ----------------
args = parser.parse_args()
num_worker = args.num_worker
start_idx = args.start_idx
player = Player
ray.init(num_cpus=num_worker)
player = ray.remote(
num_cpus=1)(player)
players = []
for i in range(num_worker):
players.append(
player.remote(idx=start_idx+i)
)
ray.get([p.run.remote() for p in players])
# ---------------------------------------