Create a synthetic GPUInfo from a GPU name. Looks up specs from the dbgpu database (2000+ GPUs). Args: name: GPU name (e.g. "RTX 4090", "RX 7900 XTX"). vram_override_gb: Override VRAM in GB. Required if GPU not in database. Returns: GPUInfo with ``(simulated)``
(name: str, vram_override_gb: float | None = None)
| 254 | |
| 255 | |
| 256 | def create_synthetic_gpu(name: str, vram_override_gb: float | None = None) -> GPUInfo: |
| 257 | """Create a synthetic GPUInfo from a GPU name. |
| 258 | |
| 259 | Looks up specs from the dbgpu database (2000+ GPUs). |
| 260 | |
| 261 | Args: |
| 262 | name: GPU name (e.g. "RTX 4090", "RX 7900 XTX"). |
| 263 | vram_override_gb: Override VRAM in GB. Required if GPU not in database. |
| 264 | |
| 265 | Returns: |
| 266 | GPUInfo with ``(simulated)`` suffix in the name. |
| 267 | |
| 268 | Raises: |
| 269 | ValueError: If GPU is not found and no vram_override_gb given. |
| 270 | """ |
| 271 | _last_suggestions.clear() |
| 272 | |
| 273 | amd_shared_memory_apu = _is_amd_shared_memory_apu(name) |
| 274 | curated = _lookup_curated_spec(name) |
| 275 | |
| 276 | # Apple Silicon short-circuit: dbgpu has no Apple entries, so we check |
| 277 | # first to avoid fuzzy-matching "M1" against "Rage Mobility-M1". |
| 278 | apple_hit = _lookup_apple_silicon(name) |
| 279 | if apple_hit is not None: |
| 280 | canonical, vendor, default_vram_gb, bandwidth = apple_hit |
| 281 | vram_gb = vram_override_gb if vram_override_gb is not None else default_vram_gb |
| 282 | return GPUInfo( |
| 283 | name=f"{canonical} (simulated)", |
| 284 | vendor=vendor, |
| 285 | vram_bytes=int(vram_gb * _GiB), |
| 286 | memory_bandwidth_gbps=bandwidth, |
| 287 | shared_memory=True, |
| 288 | vram_overridden=vram_override_gb is not None, |
| 289 | ) |
| 290 | |
| 291 | spec = _lookup_dbgpu(name) |
| 292 | |
| 293 | # VRAM |
| 294 | if vram_override_gb is not None: |
| 295 | vram_bytes = int(vram_override_gb * _GiB) |
| 296 | elif spec is not None and spec.memory_size_gb: |
| 297 | vram_bytes = int(spec.memory_size_gb * _GiB) |
| 298 | elif curated is not None: |
| 299 | vram_bytes = int(curated.vram_gb * _GiB) |
| 300 | else: |
| 301 | msg = f"Unknown GPU '{name}'." |
| 302 | if _last_suggestions: |
| 303 | candidates = ", ".join(n for n, _ in _last_suggestions) |
| 304 | msg += f" Did you mean: {candidates}?" |
| 305 | msg += " Use --vram to specify VRAM in GB." |
| 306 | raise ValueError(msg) |
| 307 | |
| 308 | # Bandwidth |
| 309 | bandwidth: float | None = None |
| 310 | if spec is not None and spec.memory_bandwidth_gb_s: |
| 311 | bandwidth = spec.memory_bandwidth_gb_s |
| 312 | if bandwidth is None and curated is not None: |
| 313 | bandwidth = curated.memory_bandwidth_gbps |