Exemplo n.º 1
0
def start(logdir, options=None):
    """Start profiling TensorFlow performance.

  Args:
    logdir: Profiling results log directory.
    options: `ProfilerOptions` namedtuple to specify miscellaneous profiler
      options. See example usage below.

  Raises:
    AlreadyExistsError: If a profiling session is already running.

  Example usage:
  ```python
  options = tf.profiler.experimental.ProfilerOptions(host_tracer_level = 3,
                                                     python_tracer_level = 1,
                                                     device_tracer_level = 1)
  tf.profiler.experimental.start('logdir_path', options = options)
  # Training code here
  tf.profiler.experimental.stop()
  ```

  To view the profiling results, launch TensorBoard and point it to `logdir`.
  Open your browser and go to `localhost:6006/#profile` to view profiling
  results.

  """
    global _profiler
    with _profiler_lock:
        if _profiler is not None:
            raise errors.AlreadyExistsError(None, None,
                                            'Another profiler is running.')
        _profiler = _pywrap_profiler.ProfilerSession()
        try:
            # support for namedtuple in pybind11 is missing, we change it to
            # dict type first.
            opts = dict(options._asdict()) if options is not None else {}
            _profiler.start(logdir, opts)
        except errors.AlreadyExistsError:
            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.')
            raise errors.AlreadyExistsError(None, None,
                                            'Another profiler is running.')
        except Exception:
            _profiler = None
            raise
def start(logdir, options=None):
    """Starts profiling.

  Args:
    logdir: A log directory read by TensorBoard to export the profile results.
    options: namedtuple of ProfilerOptions for miscellaneous profiler options.

  Raises:
    AlreadyExistsError: If another profiling session is running.

  Example usage:
  ```python
  tf.profiler.experimental.start(
      'logdir_path', tf.profiler.ProfilerOptions(host_tracer_level=2))
  # do your training here.
  tf.profiler.experimental.stop()
  ```

  Launch TensorBoard and point it to the same logdir you provided to this API.
  $ tensorboard --logdir=logdir_path
  Open your browser and go to localhost:6006/#profile to view profiling results.

  """
    global _profiler
    with _profiler_lock:
        if _profiler is not None:
            raise errors.AlreadyExistsError(None, None,
                                            'Another profiler is running.')
        _profiler = _pywrap_profiler.ProfilerSession()
        try:
            # support for namedtuple in pybind11 is missing, we change it to
            # dict type first.
            opts = dict(options._asdict()) if options is not None else {}
            _profiler.start(logdir, opts)
        except errors.AlreadyExistsError:
            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.')
            raise errors.AlreadyExistsError(None, None,
                                            'Another profiler is running.')
        except Exception:
            _profiler = None
            raise
Exemplo n.º 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.')
    if context.default_execution_mode == context.EAGER_MODE:
      context.ensure_initialized()
    _profiler = _pywrap_profiler.ProfilerSession()
    try:
      _profiler.start()
    except errors.AlreadyExistsError:
      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.')
      raise ProfilerAlreadyRunningError('Another profiler is running.')
Exemplo n.º 4
0
def start(logdir):
    """Starts profiling.

  Args:
    logdir: A log directory read by TensorBoard to export the profile results.

  Raises:
    AlreadyExistsError: If another profiling session is running.

  Example usage:
  ```python
  tf.profiler.experimental.start('logdir_path')
  # do your training here.
  tf.profiler.experimental.stop()
  ```

  Launch TensorBoard and point it to the same logdir you provided to this API.
  $ tensorboard --logdir=logdir_path
  Open your browser and go to localhost:6006/#profile to view profiling results.

  """
    global _profiler
    with _profiler_lock:
        if _profiler is not None:
            raise errors.AlreadyExistsError(None, None,
                                            'Another profiler is running.')
        _profiler = _pywrap_profiler.ProfilerSession()
        try:
            _profiler.start(logdir)
        except errors.AlreadyExistsError:
            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.')
            raise errors.AlreadyExistsError(None, None,
                                            'Another profiler is running.')
        except Exception:
            _profiler = None
            raise