-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.py
44 lines (36 loc) · 1.09 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
import os
import argparse
import torch
import numpy as np
import random
import os
from torch.backends import cudnn
from Options import parse_opt
from Sovlers import get_solver
def main():
# Parse arguments.
parser = argparse.ArgumentParser()
parser.add_argument('--options', type=str, help='Path to the option JSON file.', default='./Options/example.json')
args = parser.parse_args()
opt = parse_opt(args.options)
# GPU/CPU Specification.
os.environ['CUDA_VISIBLE_DEVICES'] = opt['gpu_ids']
os.environ['MKL_NUM_THREADS'] = opt['cpu_threads']
os.environ['NUMEXPR_NUM_THREADS'] = opt['cpu_threads']
os.environ['OMP_NUM_THREADS'] = opt['cpu_threads']
# Deterministic Settings.
if opt['deterministic']:
torch.manual_seed(712)
np.random.seed(712)
random.seed(712)
cudnn.deterministic = True
cudnn.benchmark = False
else:
cudnn.deterministic = False
cudnn.benchmark = True
# Create solver.
solver = get_solver(opt)
# Run.
solver.run()
if __name__ == "__main__":
main()