mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-15 21:00:47 +00:00
Summary: The other half of https://github.com/pytorch/pytorch/issues/56272. Pull Request resolved: https://github.com/pytorch/pytorch/pull/56290 Test Plan: CI should pass on the tip of this PR, and we know that the lint works because the following CI runs (before this PR was finished) failed: - https://github.com/pytorch/pytorch/runs/2384511062 - https://github.com/pytorch/pytorch/actions/runs/765036024 Reviewed By: seemethere Differential Revision: D27867219 Pulled By: samestep fbshipit-source-id: e648f07b6822867e70833e23ddafe7fb7eaca235
21 lines
706 B
Python
21 lines
706 B
Python
import os
|
|
import sys
|
|
import pathlib
|
|
|
|
import torch
|
|
|
|
DEFAULT_MINIDUMP_DIR = "/tmp/pytorch_crashes"
|
|
|
|
def enable_minidump_collection(directory=DEFAULT_MINIDUMP_DIR):
|
|
if sys.platform != "linux":
|
|
raise RuntimeError("Minidump collection is currently only implemented for Linux platforms")
|
|
|
|
if directory == DEFAULT_MINIDUMP_DIR:
|
|
pathlib.Path(directory).mkdir(parents=True, exist_ok=True)
|
|
elif not os.path.exists(directory):
|
|
raise RuntimeError(f"Directory does not exist: {directory}")
|
|
|
|
torch._C._enable_minidump_collection(directory) # type: ignore[attr-defined]
|
|
|
|
def disable_minidump_collection():
|
|
torch._C._disable_minidump_collection() # type: ignore[attr-defined]
|