Shortcuts

profilers

Classes

AdvancedProfiler

This profiler uses Python’s cProfiler to record more detailed information about time spent in each function call recorded during a given action.

BaseProfiler

If you wish to write a custom profiler, you should inhereit from this class.

PassThroughProfiler

This class should be used when you don’t want the (small) overhead of profiling.

SimpleProfiler

This profiler simply records the duration of actions (in seconds) and reports the mean duration of each action and the total time spent over the entire training run.

Profiler to check if there are any bottlenecks in your code.

class pytorch_lightning.profiler.profilers.AdvancedProfiler(output_filename=None, line_count_restriction=1.0)[source]

Bases: pytorch_lightning.profiler.profilers.BaseProfiler

This profiler uses Python’s cProfiler to record more detailed information about time spent in each function call recorded during a given action. The output is quite verbose and you should only use this if you want very detailed reports.

Parameters
  • output_filename (Optional[str]) – optionally save profile results to file instead of printing to std out when training is finished.

  • line_count_restriction (float) – this can be used to limit the number of functions reported for each action. either an integer (to select a count of lines), or a decimal fraction between 0.0 and 1.0 inclusive (to select a percentage of lines)

describe()[source]

Logs a profile report after the conclusion of the training run.

start(action_name)[source]

Defines how to start recording an action.

Return type

None

stop(action_name)[source]

Defines how to record the duration once an action is complete.

Return type

None

summary()[source]

Create profiler summary in text format.

Return type

str

class pytorch_lightning.profiler.profilers.BaseProfiler(output_streams=None)[source]

Bases: abc.ABC

If you wish to write a custom profiler, you should inhereit from this class.

Parameters

output_streams (Union[list, tuple, None]) – callable

describe()[source]

Logs a profile report after the conclusion of the training run.

Return type

None

profile(action_name)[source]

Yields a context manager to encapsulate the scope of a profiled action.

Example:

with self.profile('load training data'):
    # load training data code

The profiler will start once you’ve entered the context and will automatically stop once you exit the code block.

Return type

None

abstract start(action_name)[source]

Defines how to start recording an action.

Return type

None

abstract stop(action_name)[source]

Defines how to record the duration once an action is complete.

Return type

None

abstract summary()[source]

Create profiler summary in text format.

Return type

str

class pytorch_lightning.profiler.profilers.PassThroughProfiler[source]

Bases: pytorch_lightning.profiler.profilers.BaseProfiler

This class should be used when you don’t want the (small) overhead of profiling. The Trainer uses this class by default.

Args: output_streams: callable

start(action_name)[source]

Defines how to start recording an action.

Return type

None

stop(action_name)[source]

Defines how to record the duration once an action is complete.

Return type

None

summary()[source]

Create profiler summary in text format.

Return type

str

class pytorch_lightning.profiler.profilers.SimpleProfiler(output_filename=None)[source]

Bases: pytorch_lightning.profiler.profilers.BaseProfiler

This profiler simply records the duration of actions (in seconds) and reports the mean duration of each action and the total time spent over the entire training run.

Parameters

output_filename (Optional[str]) – optionally save profile results to file instead of printing to std out when training is finished.

describe()[source]

Logs a profile report after the conclusion of the training run.

start(action_name)[source]

Defines how to start recording an action.

Return type

None

stop(action_name)[source]

Defines how to record the duration once an action is complete.

Return type

None

summary()[source]

Create profiler summary in text format.

Return type

str

Read the Docs v: 1.0.7
Versions
latest
stable
1.0.7
1.0.6
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
0.10.0
0.9.0
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.6
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.0
0.5.3.2
0.5.3
0.4.9
release-1.0.x
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.