Uh oh!
There was an error while loading. Please reload this page.
forked from 501176225/Abacus
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
Latest commit
59 lines (56 loc) · 2.05 KB
/
Copy pathmain.py
File metadata and controls
59 lines (56 loc) · 2.05 KB
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
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# Author: raphael hao
importlogging, sys
importgrpc
fromconcurrentimportfutures
importtorch
importtorch.multiprocessingasmp
fromabacus.profilerimportprofile
fromabacus.serverimportAbacusServer, ClockServer
fromabacus.clusterimportCluster
fromabacus.trainerimporttrain_predictor
fromabacus.optionimportparse_options
fromabacus.backgroundimportbackground
importabacus.service_pb2asservice_pb2
importabacus.service_pb2_grpcasservice_pb2_grpc
if__name__=="__main__":
run_config=parse_options()
# mp.set_start_method("spawn")
torch.set_printoptions(linewidth=200)
logging.basicConfig(
stream=sys.stderr,
level=logging.DEBUGifrun_config.debugisTrueelselogging.INFO,
)
print(run_config)
ifrun_config.task=="profile":
profile(run_config=run_config)
elifrun_config.task=="server":
ifrun_config.platform=="single":
server=AbacusServer(run_config=run_config)
server.start_test()
server.stop_test()
elifrun_config.platform=="cluster":
server=grpc.server(futures.ThreadPoolExecutor(max_workers=8))
ifrun_config.policy=="Abacus":
ServerClass=AbacusServer
elifrun_config.policy=="Clock":
ServerClass=ClockServer
else:
raiseNotImplementedError
service_pb2_grpc.add_DNNServerServicer_to_server(
ServerClass(run_config=run_config), server
)
server.add_insecure_port("[::]:50051")
server.start()
server.wait_for_termination()
else:
raiseNotImplementedError
elifrun_config.task=="scheduler":
abacus_client=Cluster(run_config=run_config)
abacus_client.start_load_balancer()
abacus_client.start_long_term_test()
elifrun_config.task=="train":
train_predictor(run_config)
elifrun_config.task=="background":
background(args=run_config)