Shortcuts

Profiler

class pytorch_lightning.profilers.Profiler(dirpath=None, filename=None)[source]

Bases: abc.ABC

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

describe()[source]

Logs a profile report after the conclusion of 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:

Generator

profile_iterable(iterable, action_name)[source]

Profiles over each value of an iterable.

See deprecation message below.

Deprecated since version v1.6: Profiler.profile_iterable is deprecated in v1.6 and will be removed in v1.8.

Return type:

Generator

setup(stage=None, local_rank=None, log_dir=None)[source]

Execute arbitrary pre-profiling set-up steps.

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

teardown(stage=None)[source]

Execute arbitrary post-profiling tear-down steps.

Closes the currently open file and stream.

Return type:

None