def main(argv=None):
    '''Run NVCaffe service over RPyC. Launch this service with NVCaffe
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 = 'NVCaffe-{}'.format(cfver)
    NVCaffeService.ALIASES = ['NVCaffe', cfserv_alias]

    log = None
    if debug_flag:
        # print('DEBUGGING TF')
        log = get_logger(__file__, level=logging.DEBUG)

    server = server_builder(NVCaffeService,
                            log_obj=log,
                            gpus_on_system=gpus_on_system)

    server.start()
Beispiel #2
0
    def on_connect(self):
        '''Code that runs when a connection is created to init the service.
        According to documentation:
            Try to avoid overriding the __init__ method of the service. Place
            all initialization-related code in on_connect.
        '''
        # refer to: rpyc/core/protocol.py for various config options
        # self._conn._config.update(dict(
        #     # allow_all_attrs=True,
        #     # allow_pickle=True,
        #     # allow_getattr=True,
        #     # allow_setattr=False,
        #     # allow_delattr=False,
        #     # import_custom_exceptions=True,
        #     # instantiate_custom_exceptions=True,
        #     # instantiate_oldstyle_exceptions=True,
        # ))

        # https://stackoverflow.com/questions/13247956/python-django-spawn-background-process-and-avoid-zombie-process @IgnorePep8
        # cleanup spawn background process and avoid zombie process
        active_children()

        try:
            # If the logger was set via classmethod set_log
            self._log = self._log
        except AttributeError:
            log = get_logger(__file__, level=logging.INFO)
            # log = get_logger(__file__, level=logging.DEBUG)
            self._log = log

        log = self._log

        pid = os.getpid()
        log.debug('STARTING PROCESS: {} SERVICE: {}'.format(
            pid, self.get_service_name()))
Beispiel #3
0
def main(argv=None):
    '''Run Tensorflow service over RPyC. Launch this service with Tensorflow
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 tensorflow as tf
    tfserv_alias = 'Tensorflow-{}'.format(tf.__version__)  # @UndefinedVariable
    TensorflowService.ALIASES = ['Tensorflow', tfserv_alias]

    log = None
    if debug_flag:
        # print('DEBUGGING TF')
        log = get_logger(__file__, level=logging.DEBUG)

    server = server_builder(TensorflowService,
                            log_obj=log,
                            gpus_on_system=gpus_on_system)

    server.start()
Beispiel #4
0
def main(argv=None):
    '''Run DeepLearning service over RPyC.'''
    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

    log = None
    if debug_flag:
        # print('DEBUGGING TF')
        log = get_logger(__file__, level=logging.DEBUG)

    server = server_builder(DeepLearningService,
                            log_obj=log,
                            gpus_on_system=gpus_on_system)

    server.start()
Beispiel #5
0
    def __init__(self, ngpus, log=None, gpus_on_system=None):
        '''
        :param gpus_on_system: Only used if pynvml is not installed.
        '''
        log = get_logger(__file__, level=logging.INFO) if log is None else log

        self._log = log
        self._ngpus = ngpus

        try:
            import pynvml
            pynvml.nvmlInit()
            self._gpus_on_system = pynvml.nvmlDeviceGetCount()
            pynvml.nvmlShutdown()
        except Exception:
            self._gpus_on_system = gpus_on_system
        if self._gpus_on_system is None:
            warnings.warn(
                'UKNOWN NUMBER OF GPUS ON SYSTEM. INSTALL NVML AND PYNVML. '
                'SETTING TO 4', RuntimeWarning)
            self._gpus_on_system = 4

        self._lock_list = {}
        self._acquired = False
Beispiel #6
0
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()