-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_node.py
69 lines (59 loc) · 1.89 KB
/
main_node.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import os
# os.environ['OMP_NUM_THREADS'] = '1'
# os.environ['OPENBLAS_NUM_THREADS'] = '1'
# os.environ['MKL_NUM_THREADS'] = '1'
# os.environ['VECLIB_MAXIMUM_THREADS'] = '1'
# os.environ['NUMEXPR_NUM_THREADS'] = '1'
import argparse
import logging
import torch
torch.set_num_threads(1)
from torch.distributed import rpc
from torch.distributed import init_process_group
from fl.Node import Node as FL_Node
from ringsfl.Node import Node as RingSFL_Node
from sl.Node import Node as SL_Node
from splitfed.Node import Node as SplitFed_Node
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s - %(levelname)s - %(message)s"
)
MASTER_ADDR = "10.0.0.1"
MASTER_PORT = "23333"
GLOO_SOCKET_IFNAME = "bat0"
TP_SOCKET_IFNAME = "bat0"
# MASTER_ADDR = "127.0.0.1"
# MASTER_PORT = "23333"
# GLOO_SOCKET_IFNAME = "lo"
# TP_SOCKET_IFNAME = "lo"
parser = argparse.ArgumentParser()
parser.add_argument("rank", type=int)
parser.add_argument("world_size", type=int)
args = parser.parse_args()
logging.info(f"\n\
@@ node{args.rank} | rank: {args.rank} | world size: {args.world_size}\n\
Master Addr: {MASTER_ADDR}\n\
Master Port: {MASTER_PORT}\n\
GLOO Socket IFname: {GLOO_SOCKET_IFNAME}\n\
TP Socket IFname: {TP_SOCKET_IFNAME}")
if __name__ == "__main__":
os.environ['MASTER_ADDR'] = MASTER_ADDR
os.environ['MASTER_PORT'] = MASTER_PORT
os.environ['GLOO_SOCKET_IFNAME'] = GLOO_SOCKET_IFNAME
os.environ['TP_SOCKET_IFNAME'] = TP_SOCKET_IFNAME
init_process_group("gloo",
"tcp://" + MASTER_ADDR + ":" + MASTER_PORT,
world_size=args.world_size,
rank=args.rank,
group_name="ringsfl"
)
rpc.init_rpc(
"node" + str(args.rank),
rank=args.rank,
world_size=args.world_size,
rpc_backend_options=rpc.TensorPipeRpcBackendOptions(
rpc_timeout=0
)
)
logging.info("RPC initialized ...")
rpc.shutdown()