Access the Python profiling stats data (original) (raw)

The Python profiling provides framework metrics related to Python functions and operators in your training scripts and the SageMaker AI deep learning frameworks.

Training Modes and Phases for Python Profiling

To profile specific intervals during training to partition statistics for each of these intervals, Debugger provides tools to set modes and phases.

For training modes, use the following PythonProfileModes class:

from smdebug.profiler.python_profile_utils import PythonProfileModes

This class provides the following options:

For training phases, use the following StepPhase class:

from smdebug.profiler.analysis.utils.python_profile_analysis_utils import StepPhase

This class provides the following options:

Python Profiling Analysis Tools

Debugger supports the Python profiling with two profiling tools:

To learn more about the Python profiling options and what's collected, see Default system monitoring and customized framework profiling with different profiling options.

The following methods of the PythonProfileAnalysis,cProfileAnalysis, PyinstrumentAnalysis classes are provided to fetch and analyze the Python profiling data. Each function loads the latest data from the default S3 URI.

from smdebug.profiler.analysis.python_profile_analysis import PythonProfileAnalysis, cProfileAnalysis, PyinstrumentAnalysis

To set Python profiling objects for analysis, use the cProfileAnalysis or PyinstrumentAnalysis classes as shown in the following example code. It shows how to set a cProfileAnalysis object, and if you want to usePyinstrumentAnalysis, replace the class name.

python_analysis = cProfileAnalysis(
    local_profile_dir=tf_python_stats_dir, 
    s3_path=tj.profiler_s3_output_path
)

The following methods are available for the cProfileAnalysis andPyinstrumentAnalysis classes to fetch the Python profiling stats data:

The cProfileAnalysis class specific methods: