Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/tests/ampere/doctor.py # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / ampere / doctor.py` 89 lines · 4062 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 """Read-only qualification preflight. Never opens a GPU or changes its driver.""" 4 import argparse 5 import json 6 import os 7 from pathlib import Path 8 import platform 9 import re 10 import sys 11 12 # NVIDIA open-gpu-kernel-modules 580.173.02 README Compatible GPUs table. 13 # Only GA102/GA104 IDs requested by this port. Other 3060 Ti die variants refuse. 14 CARDS = {"0x2204": ("RTX 3090", "GA102"), 15 "0x2486": ("RTX 3060 Ti", "GA104"), 16 "0x2489": ("RTX 3060 Ti", "GA104")} 17 ABI = "580.173.02" 18 19 def inspect(root=Path("/"), bdf=None, machine=None): 20 simulated = root.resolve() != Path("/") 21 problems = [] 22 def text(name): 23 try: 24 return (root / name).read_text().strip() 25 except OSError: 26 return "" 27 machine = machine or platform.machine() 28 if machine != "x86_64": 29 problems.append("host must be Linux x86_64 for this device plan") 30 if platform.system() != "Linux": 31 problems.append("host OS must be Linux") 32 module = text("proc/driver/nvidia/version") 33 open_module = "Open Kernel Module" in module 34 version = re.search(r"\b([0-9]+\.[0-9]+\.[0-9]+)\b", module) 35 version = version.group(1) if version else None 36 if not open_module: 37 problems.append("NVIDIA open kernel module must be loaded") 38 if version != ABI: 39 problems.append("driver ABI must match vendored " + ABI + "; do not force another version") 40 cards = [] 41 for device in sorted((root / "sys/bus/pci/devices").glob("*")): 42 try: 43 vendor = (device / "vendor").read_text().strip().lower() 44 kind = (device / "device").read_text().strip().lower() 45 pci_class = (device / "class").read_text().strip().lower() 46 except OSError: 47 continue 48 if vendor != "0x10de" or not pci_class.startswith("0x03"): 49 continue 50 if bdf and device.name != bdf: 51 continue 52 identity = CARDS.get(kind) 53 cards.append({"bdf": device.name, "pci_device": kind, 54 "name": identity[0] if identity else "unsupported NVIDIA GPU", 55 "die": identity[1] if identity else None, 56 "target": "sm_86" if identity else None}) 57 if len(cards) != 1: 58 problems.append("select exactly one target GPU with --bdf (or attach exactly one)") 59 elif cards[0]["target"] != "sm_86": 60 problems.append("selected PCI ID is not a requested GA102/GA104 target") 61 nodes = ["nvidiactl", "nvidia-uvm"] 62 if len(cards) == 1: 63 info = text("proc/driver/nvidia/gpus/" + cards[0]["bdf"] + "/information") 64 minor = re.search(r"^Device Minor:\s*([0-9]+)\s*$", info, re.MULTILINE) 65 if not minor: 66 problems.append("selected GPU has no driver Device Minor mapping") 67 else: 68 cards[0]["device_node"] = "/dev/nvidia" + minor.group(1) 69 nodes.append("nvidia" + minor.group(1)) 70 for node in nodes: 71 path = root / "dev" / node 72 if not path.exists() or not os.access(path, os.R_OK | os.W_OK): 73 problems.append("missing/inaccessible /dev/" + node) 74 return {"preflight": "FAIL" if problems else "PASS", "evidence": "SIMULATED" if simulated else "OBSERVED", 75 "device_execution": "NOT_RUN", "machine": machine, "driver_version": version, 76 "open_module": open_module, "gpus": cards, "problems": problems, 77 "note": "Preflight PASS is not hardware qualification or permission to submit work."} 78 79 def main(): 80 parser = argparse.ArgumentParser(description=__doc__) 81 parser.add_argument("--root", type=Path, default=Path("/"), help="fake machine root; results labeled SIMULATED") 82 parser.add_argument("--bdf", help="selected full PCI address, e.g. 0000:01:00.0") 83 args = parser.parse_args() 84 report = inspect(args.root, args.bdf) 85 print(json.dumps(report, indent=2, sort_keys=True)) 86 return 0 if report["preflight"] == "PASS" else 1 87 88 if __name__ == "__main__": 89 sys.exit(main())