mate-runtime-cuda 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mate_runtime_cuda/__init__.py +28 -0
- mate_runtime_cuda/_detect.py +85 -0
- mate_runtime_cuda/_names.py +95 -0
- mate_runtime_cuda-0.1.0.dist-info/METADATA +15 -0
- mate_runtime_cuda-0.1.0.dist-info/RECORD +7 -0
- mate_runtime_cuda-0.1.0.dist-info/WHEEL +4 -0
- mate_runtime_cuda-0.1.0.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from mate_bench.plugin import PluginManifest
|
|
6
|
+
|
|
7
|
+
from ._detect import GpuInfo, is_cuda_available, query_gpu
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class CudaRuntime:
|
|
11
|
+
name = "cuda"
|
|
12
|
+
manifest = PluginManifest(requires_mate_bench=">=0.1,<0.2", api_version=1)
|
|
13
|
+
|
|
14
|
+
def is_available(self) -> bool:
|
|
15
|
+
return is_cuda_available()
|
|
16
|
+
|
|
17
|
+
def gpu_info(self, index: int = 0) -> dict[str, Any]:
|
|
18
|
+
info: GpuInfo = query_gpu(index)
|
|
19
|
+
return {
|
|
20
|
+
"gpu_vendor": "nvidia",
|
|
21
|
+
"gpu_name": info.name,
|
|
22
|
+
"gpu_chip": info.chip,
|
|
23
|
+
"vram_gb": info.vram_gb,
|
|
24
|
+
"runtime": info.cuda_version,
|
|
25
|
+
"driver": info.driver_version,
|
|
26
|
+
"_gpu_name_raw": info.name_raw,
|
|
27
|
+
"_gpu_name_known": info.name_known,
|
|
28
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
import subprocess
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
from ._names import chip_from_name, normalize
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class GpuInfo:
|
|
12
|
+
chip: str # die codename, e.g. "AD102"
|
|
13
|
+
name: str # normalized, e.g. "RTX 4090"
|
|
14
|
+
name_raw: str # as reported by nvidia-smi, e.g. "NVIDIA GeForce RTX 4090"
|
|
15
|
+
name_known: bool # False → unknown model, stored raw + flagged
|
|
16
|
+
vram_gb: float
|
|
17
|
+
cuda_version: str # e.g. "CUDA 12.4"
|
|
18
|
+
driver_version: str # e.g. "550.54.15"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def is_cuda_available() -> bool:
|
|
22
|
+
"""CUDA is available if nvidia-smi lists at least one GPU."""
|
|
23
|
+
return bool(_run(["nvidia-smi", "-L"]))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def query_gpu(index: int = 0) -> GpuInfo:
|
|
27
|
+
"""Query GPU info for the given device index via nvidia-smi."""
|
|
28
|
+
rows = _query_smi(
|
|
29
|
+
["name", "memory.total", "driver_version", "cuda_version"],
|
|
30
|
+
units=False,
|
|
31
|
+
)
|
|
32
|
+
if not rows:
|
|
33
|
+
raise RuntimeError("No NVIDIA GPU found. Are the drivers installed?")
|
|
34
|
+
if index >= len(rows):
|
|
35
|
+
raise IndexError(f"GPU index {index} out of range ({len(rows)} GPUs found)")
|
|
36
|
+
|
|
37
|
+
row = rows[index]
|
|
38
|
+
raw_name = row[0].strip()
|
|
39
|
+
vram_mib = _parse_float(row[1])
|
|
40
|
+
driver = row[2].strip()
|
|
41
|
+
cuda = row[3].strip()
|
|
42
|
+
|
|
43
|
+
name, name_known = normalize(raw_name)
|
|
44
|
+
chip, chip_known = chip_from_name(name)
|
|
45
|
+
if not chip_known:
|
|
46
|
+
chip = name # fall back to display name as chip key
|
|
47
|
+
|
|
48
|
+
return GpuInfo(
|
|
49
|
+
chip=chip,
|
|
50
|
+
name=name,
|
|
51
|
+
name_raw=raw_name,
|
|
52
|
+
name_known=name_known and chip_known,
|
|
53
|
+
vram_gb=round(vram_mib / 1024, 1),
|
|
54
|
+
cuda_version=f"CUDA {cuda}" if cuda else "CUDA unknown",
|
|
55
|
+
driver_version=driver or "unknown",
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
# ── internal helpers ──────────────────────────────────────────────────────────
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _run(cmd: list[str], timeout: int = 10) -> str:
|
|
63
|
+
try:
|
|
64
|
+
result = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
|
|
65
|
+
return result.stdout
|
|
66
|
+
except (FileNotFoundError, subprocess.TimeoutExpired, OSError):
|
|
67
|
+
return ""
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _query_smi(fields: list[str], units: bool = False) -> list[list[str]]:
|
|
71
|
+
"""Run nvidia-smi --query-gpu and return parsed rows."""
|
|
72
|
+
cmd = [
|
|
73
|
+
"nvidia-smi",
|
|
74
|
+
f"--query-gpu={','.join(fields)}",
|
|
75
|
+
"--format=csv,noheader" + ("" if units else ",nounits"),
|
|
76
|
+
]
|
|
77
|
+
out = _run(cmd)
|
|
78
|
+
if not out.strip():
|
|
79
|
+
return []
|
|
80
|
+
return [line.split(",") for line in out.strip().splitlines() if line.strip()]
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _parse_float(s: str) -> float:
|
|
84
|
+
m = re.search(r"[\d.]+", s)
|
|
85
|
+
return float(m.group()) if m else 0.0
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
# (substring to match in normalized name, chip codename)
|
|
6
|
+
# Ordered from most specific to least specific.
|
|
7
|
+
_GPU_CHIP_MAP: list[tuple[str, str]] = [
|
|
8
|
+
# Blackwell — RTX 50xx
|
|
9
|
+
("RTX 5090", "GB202"),
|
|
10
|
+
("RTX 5080", "GB203"),
|
|
11
|
+
("RTX 5070 Ti", "GB203"),
|
|
12
|
+
("RTX 5070", "GB205"),
|
|
13
|
+
("RTX 5060 Ti", "GB206"),
|
|
14
|
+
("RTX 5060", "GB206"),
|
|
15
|
+
# Ada Lovelace — RTX 40xx + professional
|
|
16
|
+
("RTX 6000 Ada", "AD102"),
|
|
17
|
+
("RTX 4090", "AD102"),
|
|
18
|
+
("RTX 4080 Super", "AD103"),
|
|
19
|
+
("RTX 4080", "AD103"),
|
|
20
|
+
("RTX 4070 Ti Super", "AD103"),
|
|
21
|
+
("RTX 4070 Ti", "AD104"),
|
|
22
|
+
("RTX 4070 Super", "AD104"),
|
|
23
|
+
("RTX 4070", "AD104"),
|
|
24
|
+
("RTX 4500 Ada", "AD104"),
|
|
25
|
+
("RTX 4000 Ada", "AD104"),
|
|
26
|
+
("RTX 4060 Ti", "AD106"),
|
|
27
|
+
("RTX 4060", "AD107"),
|
|
28
|
+
# Hopper
|
|
29
|
+
("H200", "GH200"),
|
|
30
|
+
("H100", "GH100"),
|
|
31
|
+
# Ampere — data centre
|
|
32
|
+
("A100", "GA100"),
|
|
33
|
+
("A800", "GA100"),
|
|
34
|
+
("RTX A6000", "GA102"),
|
|
35
|
+
("RTX A5000", "GA102"),
|
|
36
|
+
("RTX A4000", "GA104"),
|
|
37
|
+
("RTX A3000", "GA104"),
|
|
38
|
+
("RTX A2000", "GA106"),
|
|
39
|
+
# Ampere — RTX 30xx
|
|
40
|
+
("RTX 3090 Ti", "GA102"),
|
|
41
|
+
("RTX 3090", "GA102"),
|
|
42
|
+
("RTX 3080 Ti", "GA102"),
|
|
43
|
+
("RTX 3080", "GA102"),
|
|
44
|
+
("RTX 3070 Ti", "GA104"),
|
|
45
|
+
("RTX 3070", "GA104"),
|
|
46
|
+
("RTX 3060 Ti", "GA104"),
|
|
47
|
+
("RTX 3060", "GA106"),
|
|
48
|
+
("RTX 3050", "GA107"),
|
|
49
|
+
# Volta
|
|
50
|
+
("Titan V", "GV100"),
|
|
51
|
+
("V100", "GV100"),
|
|
52
|
+
# Turing — RTX 20xx
|
|
53
|
+
("RTX 2080 Ti", "TU102"),
|
|
54
|
+
("RTX 2080 Super", "TU104"),
|
|
55
|
+
("RTX 2080", "TU104"),
|
|
56
|
+
("RTX 2070 Super", "TU104"),
|
|
57
|
+
("RTX 2070", "TU106"),
|
|
58
|
+
("RTX 2060 Super", "TU106"),
|
|
59
|
+
("RTX 2060", "TU106"),
|
|
60
|
+
# Turing — GTX 16xx
|
|
61
|
+
("GTX 1660 Ti", "TU116"),
|
|
62
|
+
("GTX 1660 Super", "TU116"),
|
|
63
|
+
("GTX 1660", "TU116"),
|
|
64
|
+
("GTX 1650 Super", "TU116"),
|
|
65
|
+
("GTX 1650", "TU117"),
|
|
66
|
+
# Pascal — GTX 10xx
|
|
67
|
+
("Titan Xp", "GP102"),
|
|
68
|
+
("GTX 1080 Ti", "GP102"),
|
|
69
|
+
("GTX 1080", "GP104"),
|
|
70
|
+
("GTX 1070 Ti", "GP104"),
|
|
71
|
+
("GTX 1070", "GP104"),
|
|
72
|
+
("GTX 1060", "GP106"),
|
|
73
|
+
("GTX 1050 Ti", "GP107"),
|
|
74
|
+
("GTX 1050", "GP107"),
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
_STRIP_PREFIX = re.compile(r"^(?:NVIDIA\s+)?(?:GeForce\s+|Tesla\s+|Quadro\s+)?", re.IGNORECASE)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def normalize(raw: str) -> tuple[str, bool]:
|
|
81
|
+
"""Return (display_name, is_known_chip).
|
|
82
|
+
|
|
83
|
+
Strips vendor/product-line prefixes and looks up the die codename.
|
|
84
|
+
"""
|
|
85
|
+
display = _STRIP_PREFIX.sub("", raw).strip()
|
|
86
|
+
_, known = chip_from_name(display)
|
|
87
|
+
return display, known
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def chip_from_name(normalized: str) -> tuple[str, bool]:
|
|
91
|
+
"""Return (chip_codename, is_known) for a normalized GPU name."""
|
|
92
|
+
for substring, chip in _GPU_CHIP_MAP:
|
|
93
|
+
if substring.lower() in normalized.lower():
|
|
94
|
+
return chip, True
|
|
95
|
+
return normalized, False
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mate-runtime-cuda
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: NVIDIA CUDA runtime plugin for mate-bench
|
|
5
|
+
Project-URL: Homepage, https://github.com/T0nd3/mate-bench
|
|
6
|
+
Project-URL: Repository, https://github.com/T0nd3/mate-bench
|
|
7
|
+
Author-email: Benjamin Fäuster <benjamin.faeuster@web.de>
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Topic :: System :: Benchmark
|
|
14
|
+
Requires-Python: >=3.11
|
|
15
|
+
Requires-Dist: mate-bench<0.2,>=0.1
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
mate_runtime_cuda/__init__.py,sha256=69Z8_O0ibwwHXAVYfb-KJqvWWJbmikY6pqp0SvJRqMM,802
|
|
2
|
+
mate_runtime_cuda/_detect.py,sha256=zCN6mJiDxyYqS8cgJRmss5Zhrr8KpOYFWck9Y4d8Fg0,2711
|
|
3
|
+
mate_runtime_cuda/_names.py,sha256=i72SQVyr1GemtaErcZBPXbTsD2U_xO9bybP14jKIRFs,2746
|
|
4
|
+
mate_runtime_cuda-0.1.0.dist-info/METADATA,sha256=R0UQ7GBEGQqK8XwvtlhgpORZEzcrSmeYXqqqPCW4iPs,606
|
|
5
|
+
mate_runtime_cuda-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
6
|
+
mate_runtime_cuda-0.1.0.dist-info/entry_points.txt,sha256=dkrl3sdi-_eyTc4dgsMiCJOyFZ9bBxZCEicN9_72IdI,58
|
|
7
|
+
mate_runtime_cuda-0.1.0.dist-info/RECORD,,
|