start_profiler

paddle.utils.profiler. start_profiler ( state, tracer_option='Default' ) [source]

Enable the profiler. Uers can use fluid.profiler.start_profiler and fluid.profiler.stop_profiler to profile, which is equal to the usage of fluid.profiler.profiler interface.

Parameters
  • state (str) – The profiling state, which should be one of ‘CPU’, ‘GPU’ or ‘All’. ‘CPU’ means only profiling CPU; ‘GPU’ means profiling both CPU and GPU; ‘All’ means profiling both CPU and GPU, and generates timeline as well.

  • tracer_option (str, optional) – tracer_option can be one of [‘Default’, ‘OpDetail’, ‘AllOpDetail’], it can control the profile level and print the different level profile result. Default option print the different Op type profiling result and the OpDetail option print the detail profiling result of different op types such as compute and data transform, AllOpDetail option print the detail profiling result of different op name same as OpDetail.

Raises

ValueError – If state is not in [‘CPU’, ‘GPU’, ‘All’] or tracer_option is not in [‘Default’, ‘OpDetail’, ‘AllOpDetail’].

Examples

# required: gpu
import paddle.fluid as fluid
import paddle.fluid.profiler as profiler

profiler.start_profiler('GPU')
for iter in range(10):
    if iter == 2:
        profiler.reset_profiler()
    # except each iteration
profiler.stop_profiler('total', '/tmp/profile')

profiler.start_profiler('GPU', "OpDetail")
for iter in range(10):
    if iter == 2:
        profiler.reset_profiler()
    # except each iteration
profiler.stop_profiler('total', '/tmp/profile')