empty_gpu_cache() — pytorch Function Reference
Architecture documentation for the empty_gpu_cache() function in common.py from the pytorch codebase.
Entity Profile
Dependency Diagram
graph TD 06ff896d_4db0_aa47_b3cd_be1da620f0ea["empty_gpu_cache()"] 3df8de63_d71a_714c_93a1_1a0e24c0f362["load()"] 3df8de63_d71a_714c_93a1_1a0e24c0f362 -->|calls| 06ff896d_4db0_aa47_b3cd_be1da620f0ea ba74afb9_ef25_84a8_66e2_1d25dcee421f["batch_size_finder()"] ba74afb9_ef25_84a8_66e2_1d25dcee421f -->|calls| 06ff896d_4db0_aa47_b3cd_be1da620f0ea 79f63331_206c_51dc_bfd1_4fd84b939754["check_accuracy()"] 79f63331_206c_51dc_bfd1_4fd84b939754 -->|calls| 06ff896d_4db0_aa47_b3cd_be1da620f0ea c52cc8f1_b576_9d50_98d9_34f721215c0e["run_performance_test_non_alternate()"] c52cc8f1_b576_9d50_98d9_34f721215c0e -->|calls| 06ff896d_4db0_aa47_b3cd_be1da620f0ea d162fe35_2cc5_7738_ed94_76ad697846ef["run_performance_test()"] d162fe35_2cc5_7738_ed94_76ad697846ef -->|calls| 06ff896d_4db0_aa47_b3cd_be1da620f0ea 9bf8449e_2d7f_c370_514b_b3c7bf20f8e1["run_one_model()"] 9bf8449e_2d7f_c370_514b_b3c7bf20f8e1 -->|calls| 06ff896d_4db0_aa47_b3cd_be1da620f0ea style 06ff896d_4db0_aa47_b3cd_be1da620f0ea fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
benchmarks/dynamo/common.py lines 562–574
def empty_gpu_cache(device):
"""
Explicitly empty gpu cache to avoid OOM in subsequent run.
"""
if device not in ["cuda", "xpu", "mps"]:
log.warning(
"Trying to call the empty_gpu_cache for device: %s, which is not in list [cuda, xpu]",
device,
)
return
getattr(torch, device).empty_cache()
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does empty_gpu_cache() do?
empty_gpu_cache() is a function in the pytorch codebase.
What calls empty_gpu_cache()?
empty_gpu_cache() is called by 6 function(s): batch_size_finder, check_accuracy, load, run_one_model, 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