Show GPU status information.
()
| 189 | |
| 190 | |
| 191 | def show_gpu_status(): |
| 192 | """Show GPU status information.""" |
| 193 | console.print("\n[nvidia]GPU STATUS[/nvidia]\n") |
| 194 | |
| 195 | try: |
| 196 | import subprocess |
| 197 | |
| 198 | # Try nvidia-smi for detailed info |
| 199 | result = subprocess.run( |
| 200 | ['nvidia-smi', '--query-gpu=name,memory.total,memory.used,memory.free,temperature.gpu,utilization.gpu', |
| 201 | '--format=csv,noheader,nounits'], |
| 202 | capture_output=True, |
| 203 | text=True, |
| 204 | timeout=3 |
| 205 | ) |
| 206 | |
| 207 | if result.returncode == 0 and result.stdout.strip(): |
| 208 | lines = result.stdout.strip().split('\n') |
| 209 | for idx, line in enumerate(lines): |
| 210 | parts = [p.strip() for p in line.split(',')] |
| 211 | if len(parts) >= 6: |
| 212 | name, mem_total, mem_used, mem_free, temp, util = parts[:6] |
| 213 | |
| 214 | console.print(f"[nvidia]GPU {idx}:[/nvidia] {name}") |
| 215 | console.print(f" Memory: {mem_used}/{mem_total} MB ({float(mem_used)/float(mem_total)*100:.1f}% used)") |
| 216 | console.print(f" Temperature: {temp}°C") |
| 217 | console.print(f" Utilization: {util}%") |
| 218 | console.print() |
| 219 | else: |
| 220 | # Fallback to basic detection |
| 221 | gpu_name, gpu_available = detect_gpu_info() |
| 222 | cuda_version = detect_cuda_version() |
| 223 | |
| 224 | if gpu_name: |
| 225 | console.print(f"[nvidia]GPU:[/nvidia] {gpu_name}") |
| 226 | else: |
| 227 | console.print("[nvidia_dim]No GPU detected[/nvidia_dim]") |
| 228 | |
| 229 | if cuda_version: |
| 230 | console.print(f"[nvidia]CUDA:[/nvidia] Version {cuda_version}") |
| 231 | else: |
| 232 | console.print("[nvidia_dim]CUDA not found[/nvidia_dim]") |
| 233 | console.print() |
| 234 | |
| 235 | except Exception as e: |
| 236 | console.print("[yellow]Could not retrieve GPU status[/yellow]") |
| 237 | console.print(f"[dim]Error: {str(e)[:100]}[/dim]\n") |
| 238 | |
| 239 | |
| 240 | def handle_command(orchestrator: AgentOrchestrator, cmd: str) -> bool: |
no test coverage detected