-
Notifications
You must be signed in to change notification settings - Fork 1
/
cfrpyc_server.py
66 lines (47 loc) · 1.7 KB
/
cfrpyc_server.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
#!/usr/bin/env python
'''
For this service to self register must start the registry client prior to
starting this service.
'''
import sys
import logging
import shlex
import subprocess
import rpyc
from cli_servers_common import parser_
from rpycdl_lib.common import get_logger
from rpycdl_lib.dlrpyc_services import DLServiceMixin, server_builder
class CaffeService(DLServiceMixin, rpyc.Service):
'''Caffe RPyC Service'''
# def __init__(self, *args, **kwargs):
# rpyc.Service.__init__(self, *args, **kwargs)
def main(argv=None):
'''Run Caffe service over RPyC. Launch this service with Caffe
istalled on the system. If using containers, then launch this service from
within the container.
'''
desc = '{}{}'.format(__doc__, main.__doc__)
argv = sys.argv if argv is None else sys.argv.extend(argv)
# CLI parser
args = parser_(desc)
debug_flag = args.debug
gpus_on_system = args.ngpus
# import caffe as cf # @UnresolvedImport
# cfserv_alias = 'Caffe-{}'.format(cf.__version__) # @UndefinedVariable
cfver = subprocess.check_output(shlex.split('caffe --version')).split()[-1]
cfserv_alias = 'Caffe-{}'.format(cfver)
CaffeService.ALIASES = ['Caffe', cfserv_alias]
# refer to: rpyc/core/protocol.py for various config options
# protocol_config = {
# # 'allow_pickle': True,
# # 'allow_public_attrs': True
# } # pass customized protocol_config to server_builder
log = None
if debug_flag:
# print('DEBUGGING TF')
log = get_logger(__file__, level=logging.DEBUG)
server = server_builder(
CaffeService, log_obj=log, gpus_on_system=gpus_on_system)
server.start()
if __name__ == "__main__":
main()