def start_grpc_stub_if_necessary(self): # We will enable streaming trace viewer on two conditions: # 1. user specify the flags master_tpu_unsecure_channel to the ip address of # as "master" TPU. grpc will be used to fetch streaming trace data. # 2. the logdir is on google cloud storage. if self.master_tpu_unsecure_channel and self.logdir.startswith('gs://'): if self.stub is None: import grpc from tensorflow.python.tpu.profiler import profiler_analysis_pb2_grpc # pylint: disable=line-too-long # Workaround the grpc's 4MB message limitation. gigabyte = 1024 * 1024 * 1024 options = [('grpc.max_message_length', gigabyte), ('grpc.max_send_message_length', gigabyte), ('grpc.max_receive_message_length', gigabyte)] tpu_profiler_port = self.master_tpu_unsecure_channel + ':8466' channel = grpc.insecure_channel(tpu_profiler_port, options) self.stub = profiler_analysis_pb2_grpc.ProfileAnalysisStub(channel)
def start_grpc_stub_if_necessary(self): # We will enable streaming trace viewer on two conditions: # 1. user specify the flags master_tpu_unsecure_channel to the ip address of # as "master" TPU. grpc will be used to fetch streaming trace data. # 2. the logdir is on google cloud storage. if self.master_tpu_unsecure_channel and self.logdir.startswith('gs://'): if self.stub is None: # gRPC and profiler_analysis are only needed to support streaming trace # viewer in Cloud TPU. This code is unused when data was produced by # open-source TensorFlow. Only import the libraries when needed. # pylint: disable=g-import-not-at-top import grpc from tensorflow.python.tpu.profiler import profiler_analysis_pb2_grpc # pylint: enable=g-import-not-at-top # Workaround the grpc's 4MB message limitation. gigabyte = 1024 * 1024 * 1024 options = [('grpc.max_message_length', gigabyte), ('grpc.max_send_message_length', gigabyte), ('grpc.max_receive_message_length', gigabyte)] tpu_profiler_port = self.master_tpu_unsecure_channel + ':8466' channel = grpc.insecure_channel(tpu_profiler_port, options) self.stub = profiler_analysis_pb2_grpc.ProfileAnalysisStub(channel)