Home / Function/ maybe_snapshot_memory() — pytorch Function Reference

maybe_snapshot_memory() — pytorch Function Reference

Architecture documentation for the maybe_snapshot_memory() function in common.py from the pytorch codebase.

Entity Profile

Dependency Diagram

graph TD
  2e9cdee4_896b_80c3_3a69_14e0ea0cfb08["maybe_snapshot_memory()"]
  c52cc8f1_b576_9d50_98d9_34f721215c0e["run_performance_test_non_alternate()"]
  c52cc8f1_b576_9d50_98d9_34f721215c0e -->|calls| 2e9cdee4_896b_80c3_3a69_14e0ea0cfb08
  d162fe35_2cc5_7738_ed94_76ad697846ef["run_performance_test()"]
  d162fe35_2cc5_7738_ed94_76ad697846ef -->|calls| 2e9cdee4_896b_80c3_3a69_14e0ea0cfb08
  style 2e9cdee4_896b_80c3_3a69_14e0ea0cfb08 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

benchmarks/dynamo/common.py lines 1759–1778

def maybe_snapshot_memory(should_snapshot_memory, suffix):
    # Enables Memory Snapshot tool for memory deep dives:
    # https://pytorch.org/blog/understanding-gpu-memory-1/
    try:
        if should_snapshot_memory:
            torch.cuda.memory._record_memory_history(max_entries=100000)
        yield
    finally:
        if should_snapshot_memory:
            try:
                torch.cuda.memory._dump_snapshot(
                    os.path.join(
                        torch._dynamo.config.base_dir,
                        f"{output_filename.rstrip('.csv')}_{suffix}.pickle",
                    )
                )
            except Exception:
                log.exception("Failed to save memory snapshot")

            torch.cuda.memory._record_memory_history(enabled=None)

Subdomains

Frequently Asked Questions

What does maybe_snapshot_memory() do?
maybe_snapshot_memory() is a function in the pytorch codebase.
What calls maybe_snapshot_memory()?
maybe_snapshot_memory() is called by 2 function(s): run_performance_test, run_performance_test_non_alternate.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free