-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
30 lines (26 loc) · 854 Bytes
/
run.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
from step import train
import sys
import configparser
import numpy as np
import torch
import os
config = configparser.ConfigParser()
config.read(sys.argv[1])
SEED = 0
torch.manual_seed(SEED)
torch.cuda.manual_seed(SEED)
np.random.seed(SEED)
# torch.backends.cudnn.benchmark = True
os.environ['CUDA_VISIBLE_DEVICES'] = config['DEFAULT']['GPU']
os.makedirs("{}/{}".format(config['Paths']['checkpoint_dir'], config['DEFAULT']['name']), exist_ok=True)
if __name__ == '__main__':
import torch
with torch.autograd.set_detect_anomaly(True):
if len(sys.argv) < 2:
raise RuntimeError('Please provide at least two arguments')
if sys.argv[2] == '1':
train.trainer(config)
elif sys.argv[2] == '2':
cross_model.trainer(config)
else:
raise ValueError('Invalid Training Type')