paddle.utils.profiler. stop_profiler ( sorted_key=None, profile_path='/tmp/profile' ) [source]

Stop 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.

  • sorted_key (str, optional) – The order of profiling results, which should be one of None, ‘calls’, ‘total’, ‘max’, ‘min’ or ‘ave’. Default is None, means the profiling results will be printed in the order of first end time of events. The calls means sorting by the number of calls. The total means sorting by the total execution time. The max means sorting by the maximum execution time. The min means sorting by the minimum execution time. The ave means sorting by the average execution time. and write it into profile_path. The default profile_path is /tmp/profile.

  • profile_path (str, optional) – If state == ‘All’, it will generate timeline,


ValueError – If sorted_key is not in [‘calls’, ‘total’, ‘max’, ‘min’, ‘ave’].


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

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