start_profiler

paddle.fluid.profiler.start_profiler(state)[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.

Raises

ValueError – If state is not in [‘CPU’, ‘GPU’, ‘All’].

Examples

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')