-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.py
55 lines (40 loc) · 1.31 KB
/
main.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
"""
__author__ = "Qingbiao Li and Chenning YU"
Main
-Capture the config file
-Process the json config passed
-Create an agent instance
-Run the agent
"""
import argparse
from utils.config import *
from agents import *
from configs.str2config import str2config, add_default_argument_and_parse
# Pick specific CPU
# os.system("taskset -p -c 0 %d" % (os.getpid()))
# os.system("taskset -p 0xFFFFFFFF %d" % (os.getpid()))
# os.system("taskset -p -c 0-7,16-23 %d" % (os.getpid()))
# os.system("taskset -p -c 8-15,24-31 %d" % (os.getpid()))
# Pick specific GPU
# os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
# os.environ["CUDA_VISIBLE_DEVICES"] = "0,1,2, 3"
## Main Pro
def main():
# parse the path of the json config file
arg_parser = argparse.ArgumentParser(description="Start the experiment agent")
config_setup = add_default_argument_and_parse(arg_parser, 'experiment')
print(config_setup.agent)
# parse the config json file
config = process_config(config_setup)
print(config.seed)
# set random seed
seed_everything(config.seed)
print(config.seed)
# Create the Agent and pass all the configuration to it then run it..
agent_class = globals()[config.agent]
agent = agent_class(config)
print(agent)
agent.run()
agent.finalize()
if __name__ == '__main__':
main()