Repository navigation
Expand file tree
/
Copy path__main__.py
More file actions
73 lines (65 loc) · 2.44 KB
/
Copy path__main__.py
File metadata and controls
73 lines (65 loc) · 2.44 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
# SPDX-License-Identifier: Apache-2.0
"""Inspect AFDEP runtime requirements without creating a communicator."""
from __future__ import annotations
import argparse
import json
import platform
from . import __version__
from ._build import load_deepep, nccl_paths, resolve_nvcc, source_digest
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("command", choices=["doctor"])
parser.add_argument(
"--build", action="store_true", help="Compile/load CUDA extension"
)
args = parser.parse_args()
report: dict = {
"afdep": __version__,
"platform": platform.platform(),
"source_digest": source_digest(),
"errors": [],
}
try:
import torch
report.update(
torch=torch.__version__,
torch_cuda=torch.version.cuda,
cuda_available=torch.cuda.is_available(),
)
if torch.cuda.is_available():
props = torch.cuda.get_device_properties(torch.cuda.current_device())
report.update(
gpu=props.name,
capability=list(torch.cuda.get_device_capability()),
sm_count=props.multi_processor_count,
)
else:
report["errors"].append("No CUDA GPU is available")
except ImportError as exc:
report["errors"].append(str(exc))
for key, operation in (("nvcc", resolve_nvcc), ("nccl", nccl_paths)):
try:
value = operation()
report[key] = (
[str(p) for p in value] if isinstance(value, tuple) else str(value)
)
except RuntimeError as exc:
report["errors"].append(str(exc))
if args.build:
try:
module = load_deepep()
report["native_library"] = module.__file__
report["nccl_version"] = module.get_nccl_version()
report["compiled_nccl_version"] = module.compiled_nccl_version
if report["nccl_version"] != report["compiled_nccl_version"]:
report["errors"].append(
"NCCL headers differ from the loaded runtime. Match "
"AFDEP_NCCL_ROOT and LD_LIBRARY_PATH before starting Python."
)
except Exception as exc:
report["errors"].append(f"{type(exc).__name__}: {exc}")
print(json.dumps(report, indent=2))
if report["errors"]:
raise SystemExit(1)
if __name__ == "__main__":
main()