-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_octopus.py
52 lines (41 loc) · 1.44 KB
/
run_octopus.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
"""
Wrapper script to run octopus.
"""
__author__ = 'ryanquinnnelson'
import sys
import os
import configparser
# TODO: find a way to avoid adding the path
# TODO: find a way to avoid hard-coding this value
# append path so we can use local octopus package
sys.path.append('/Users/ryanqnelson/GitHub/ryanquinnnelson/octopus') # local
sys.path.append('/home/ubuntu/octopus') # remote
from octopus.octopus import Octopus
from customized.datasets import DatasetHandler
from customized.models import ModelHandler
from customized.phases import PhaseHandler
from customized.optimizers import OptimizerHandler
from customized.schedulers import SchedulerHandler
# execute before loading torch
os.environ['CUDA_LAUNCH_BLOCKING'] = "1" # better error tracking from gpu
def main():
# get filename from arguments
config_file = None
for arg in sys.argv:
if '--filename=' in arg:
config_file = arg.strip().split('=')[1].strip()
# parse config file
config_contents = configparser.ConfigParser()
config_contents.read(config_file)
# initialize handlers for customized components
idh = DatasetHandler(config_contents['data']['data_dir'])
ph = PhaseHandler()
mh = ModelHandler()
oh = OptimizerHandler()
sh = SchedulerHandler()
# run octopus
octopus = Octopus(config_file, config_contents, idh, ph, mh, oh, sh)
octopus.run()
if __name__ == "__main__":
# execute only if run as a script
main()