export_chrome_tracing

paddle.profiler. export_chrome_tracing ( dir_name: str, worker_name: Optional[str] = None ) Callable [source]

Return a callable, used for outputing tracing data to chrome tracing format file. The output file will be saved in directory dir_name, and file name will be set as worker_name. if worker_name is not set, the default name is [hostname]_[pid].

Parameters
  • dir_name (str) – Directory to save profiling data.

  • worker_name (str, optional) – Prefix of the file name saved, default is [hostname]_[pid].

Returns

A callable, which takes a Profiler object as parameter and calls its export method to save data to chrome tracing format file.

Examples

The return value can be used as parameter on_trace_ready in Profiler .

>>> 
>>> import paddle.profiler as profiler
>>> import paddle
>>> paddle.device.set_device('gpu')
>>> with profiler.Profiler(
...        targets=[profiler.ProfilerTarget.CPU, profiler.ProfilerTarget.GPU],
...        scheduler = (3, 10),
...        on_trace_ready=profiler.export_chrome_tracing('./log')) as p:
...     for iter in range(10):
...        #train()
...        p.step()