-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathrun_dist.py
45 lines (37 loc) · 1.76 KB
/
run_dist.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
from src.run_exp import exp_centralized, exp_centralized_for, exp_centralized_for_multi, exp_centralized_for_multi_gpu
from src.solver import QUBO_solver
import json
import torch.multiprocessing as mp
if __name__ == '__main__':
test_mode = "infer"
dataset = "stanford"
if test_mode == "infer":
if dataset == "stanford":
with open('infer_configs/maxcut_R_for.json') as f:
params = json.load(f)
elif dataset == "arxiv":
with open('infer_configs/maxcut_arxiv_for.json') as f:
params = json.load(f)
print("params", params)
exp_centralized(params)
elif test_mode == "dist":
if dataset == "stanford":
with open('dist_configs/maxcut_R_for.json') as f:
params = json.load(f)
elif dataset == "arxiv":
with open('dist_configs/maxcut_arxiv_for.json') as f:
params = json.load(f)
params["logging_path"] = params["logging_path"].split(".log")[0] +str(params["multi_gpu"]) + "_" + params["data"] + "_test.log"
if params["multi_gpu"]:
mp.spawn(exp_centralized_for_multi, args=(list(range(params["num_gpus"])), params), nprocs=params["num_gpus"])
else:
exp_centralized_for(params)
elif test_mode == "multi_gpu":
if dataset == "stanford":
with open('dist_configs/maxcut_R_for.json') as f:
params = json.load(f)
elif dataset == "arxiv":
with open('dist_configs/maxcut_arxiv_for.json') as f:
params = json.load(f)
params["logging_path"] = params["logging_path"].split(".log")[0] +str(params["multi_gpu"]) + "_" + params["data"] + "_test.log"
mp.spawn(exp_centralized_for_multi_gpu, args=(list(range(params["num_gpus"])), params), nprocs=params["num_gpus"])