Пример #1
0
def monitoring_helper(service_addr, duration_ms, monitoring_level,
                      num_queries):
    """Helper function to print monitoring results.

  Helper function to print monitoring results for num_queries times.

  Args:
    service_addr: Address of the TPU profiler service.
    duration_ms: Duration of one monitoring sample in milliseconds.
    monitoring_level: An integer between 1 and 2. Level 2 is more verbose than
      level 1 and shows more metrics.
    num_queries: Number of monitoring samples to collect.
  """
    if monitoring_level <= 0 or monitoring_level > 2:
        sys.exit('Please choose a monitoring level between 1 and 2.')

    for query in range(0, num_queries):
        res = profiler_client.monitor(service_addr, duration_ms,
                                      monitoring_level)
        print('Cloud TPU Monitoring Results (Sample ', query, '):\n\n', res)
Пример #2
0
 def testMonitor_ProcessInvalidAddress(self):
     with self.assertRaises(errors.UnavailableError):
         profiler_client.monitor('localhost:6006', 2000)
Пример #3
0
 def tpu_utilization(cls, service_addr, duration_ms, monitoring_level):
     return profiler_client.monitor(service_addr, duration_ms,
                                    monitoring_level)
Пример #4
0
 def testMonitor_ProcessInvalidAddress(self):
     # Monitor is only supported in cloud TPU. Test invalid address instead.
     with self.assertRaises(errors.UnavailableError):
         profiler_client.monitor('localhost:6006', 2000)