()
| 71 | |
| 72 | |
| 73 | def _pick_device() -> str: |
| 74 | if DEVICE: |
| 75 | return DEVICE |
| 76 | try: |
| 77 | import torch |
| 78 | if torch.backends.mps.is_available(): |
| 79 | return "mps" # Apple Silicon GPU |
| 80 | if torch.cuda.is_available(): |
| 81 | return "cuda" |
| 82 | except Exception: |
| 83 | pass |
| 84 | return "cpu" |
| 85 | |
| 86 | |
| 87 | # ── Lazy model load (so the server starts fast and reports readiness) ────── |