Shortcuts

BasicTimeProfiler#

class ignite.contrib.handlers.time_profilers.BasicTimeProfiler[source]#

BasicTimeProfiler can be used to profile the handlers, events, data loading and data processing times.

Examples:

from ignite.contrib.handlers import BasicTimeProfiler

trainer = Engine(train_updater)

# Create an object of the profiler and attach an engine to it
profiler = BasicTimeProfiler()
profiler.attach(trainer)

@trainer.on(Events.EPOCH_COMPLETED)
def log_intermediate_results():
    profiler.print_results(profiler.get_results())

trainer.run(dataloader, max_epochs=3)

profiler.write_results('path_to_dir/time_profiling.csv')

Methods

attach

Attach BasicTimeProfiler to the given engine.

get_results

Method to fetch the aggregated profiler results after the engine is run

print_results

Method to print the aggregated results from the profiler

write_results

Method to store the unaggregated profiling results to a csv file

attach(engine)[source]#

Attach BasicTimeProfiler to the given engine.

Parameters

engine (Engine) – the instance of Engine to attach

Return type

None

get_results()[source]#

Method to fetch the aggregated profiler results after the engine is run

results = profiler.get_results()
Return type

Dict[str, Dict[str, Any]]

static print_results(results)[source]#

Method to print the aggregated results from the profiler

Parameters

results (Dict) – the aggregated results from the profiler

Return type

str

profiler.print_results(results)

Example output:

 ----------------------------------------------------
| Time profiling stats (in seconds):                 |
 ----------------------------------------------------
total  |  min/index  |  max/index  |  mean  |  std

Processing function:
157.46292 | 0.01452/1501 | 0.26905/0 | 0.07730 | 0.01258

Dataflow:
6.11384 | 0.00008/1935 | 0.28461/1551 | 0.00300 | 0.02693

Event handlers:
2.82721

- Events.STARTED: []
0.00000

- Events.EPOCH_STARTED: []
0.00006 | 0.00000/0 | 0.00000/17 | 0.00000 | 0.00000

- Events.ITERATION_STARTED: ['PiecewiseLinear']
0.03482 | 0.00001/188 | 0.00018/679 | 0.00002 | 0.00001

- Events.ITERATION_COMPLETED: ['TerminateOnNan']
0.20037 | 0.00006/866 | 0.00089/1943 | 0.00010 | 0.00003

- Events.EPOCH_COMPLETED: ['empty_cuda_cache', 'training.<locals>.log_elapsed_time', ]
2.57860 | 0.11529/0 | 0.14977/13 | 0.12893 | 0.00790

- Events.COMPLETED: []
not yet triggered
write_results(output_path)[source]#

Method to store the unaggregated profiling results to a csv file

Parameters

output_path (str) – file output path containing a filename

Return type

None

profiler.write_results('path_to_dir/awesome_filename.csv')

Example output:

-----------------------------------------------------------------
epoch iteration processing_stats dataflow_stats Event_STARTED ...
1.0     1.0        0.00003         0.252387        0.125676
1.0     2.0        0.00029         0.252342        0.125123