-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstackbridge-inspect-stack
More file actions
executable file
·84 lines (67 loc) · 2.51 KB
/
Copy pathstackbridge-inspect-stack
File metadata and controls
executable file
·84 lines (67 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python3
from __future__ import annotations
import importlib
import json
import platform
import sys
import argparse
from pathlib import Path
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Inspect Python, CUDA, and training package availability.")
return parser.parse_args()
def _module_info(name: str) -> dict[str, str]:
try:
module = importlib.import_module(name)
except Exception as exc: # pragma: no cover - diagnostics only
return {"status": "error", "error": repr(exc)}
version = getattr(module, "__version__", "unknown")
location = getattr(module, "__file__", "unknown")
return {"status": "ok", "version": str(version), "location": str(location)}
def main() -> int:
parse_args()
info: dict[str, object] = {
"python": {
"executable": sys.executable,
"version": sys.version,
"platform": platform.platform(),
},
"modules": {},
}
import torch # noqa: PLC0415
cuda: dict[str, object] = {
"torch_version": torch.__version__,
"torch_cuda": torch.version.cuda,
"cuda_available": torch.cuda.is_available(),
}
if torch.cuda.is_available():
cuda.update(
{
"device_name": torch.cuda.get_device_name(0),
"device_capability": list(torch.cuda.get_device_capability(0)),
"bf16_supported": torch.cuda.is_bf16_supported(),
"flash_sdp_enabled": torch.backends.cuda.flash_sdp_enabled(),
"mem_efficient_sdp_enabled": torch.backends.cuda.mem_efficient_sdp_enabled(),
"math_sdp_enabled": torch.backends.cuda.math_sdp_enabled(),
}
)
info["cuda"] = cuda
# Import Unsloth first so its import-time patches apply before TRL / Transformers.
module_names = [
"unsloth",
"transformers",
"trl",
"xformers",
"torchvision",
"flash_attn",
]
for name in module_names:
info["modules"][name] = _module_info(name)
try:
from transformers.utils import is_flash_attn_2_available # noqa: PLC0415
info["transformers_flash_attn_2_available"] = bool(is_flash_attn_2_available())
except Exception as exc: # pragma: no cover - diagnostics only
info["transformers_flash_attn_2_available"] = {"status": "error", "error": repr(exc)}
print(json.dumps(info, indent=2))
return 0
if __name__ == "__main__":
raise SystemExit(main())