def start():
    """Start profiling.

  Raises:
    ProfilerAlreadyRunningError: If another profiling session is running.
  """
    global _profiler
    with _profiler_lock:
        if _profiler is not None:
            raise ProfilerAlreadyRunningError('Another profiler is running.')
        if context.default_execution_mode == context.EAGER_MODE:
            context.ensure_initialized()
        _profiler = pywrap_tensorflow.TFE_NewProfiler()
        if not pywrap_tensorflow.TFE_ProfilerIsOk(_profiler):
            logging.warning(
                'Another profiler session is running which is probably '
                'created by profiler server. Please avoid using profiler '
                'server and profiler APIs at the same time.')
Beispiel #2
0
def start():
    """Start profiling.

  Only one active profiling session is allowed.

  Raises:
    AssertionError: If another profiling session is running.
  """
    global _profiler
    if _profiler is not None:
        raise AssertionError('Another profiler is running.')
    with _profiler_lock:
        _profiler = pywrap_tensorflow.TFE_NewProfiler(
            context.context()._handle)  # pylint: disable=protected-access
        if not pywrap_tensorflow.TFE_ProfilerIsOk(_profiler):
            logging.warning(
                'Another profiler session is running which is probably '
                'created by profiler server. Please avoid using profiler '
                'server and profiler APIs at the same time.')
Beispiel #3
0
def start():
  """Start profiling.

  Raises:
    ProfilerAlreadyRunningError: If another profiling session is running.
  """
  global _profiler
  with _profiler_lock:
    if _profiler is not None:
      raise ProfilerAlreadyRunningError('Another profiler is running.')
    profiler_context = pywrap_tensorflow.TFE_NewProfilerContext()
    if context.default_execution_mode == context.EAGER_MODE:
      pywrap_tensorflow.TFE_ProfilerContextSetEagerContext(
          profiler_context,
          context.context()._handle)  # pylint: disable=protected-access
    _profiler = pywrap_tensorflow.TFE_NewProfiler(profiler_context)
    pywrap_tensorflow.TFE_DeleteProfilerContext(profiler_context)
    if not pywrap_tensorflow.TFE_ProfilerIsOk(_profiler):
      logging.warning('Another profiler session is running which is probably '
                      'created by profiler server. Please avoid using profiler '
                      'server and profiler APIs at the same time.')