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

Return a callable, used for outputing tracing data to protobuf 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].

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

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


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


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

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