Detect GPU and CUDA information.
()
| 105 | |
| 106 | |
| 107 | def detect_gpu_info(): |
| 108 | """Detect GPU and CUDA information.""" |
| 109 | try: |
| 110 | import subprocess |
| 111 | |
| 112 | # Try nvidia-smi to get GPU name |
| 113 | result = subprocess.run( |
| 114 | ['nvidia-smi', '--query-gpu=name', '--format=csv,noheader'], |
| 115 | capture_output=True, |
| 116 | text=True, |
| 117 | timeout=2 |
| 118 | ) |
| 119 | |
| 120 | if result.returncode == 0 and result.stdout.strip(): |
| 121 | gpu_name = result.stdout.strip().split('\n')[0] # First GPU |
| 122 | return gpu_name, True |
| 123 | else: |
| 124 | return None, False |
| 125 | except: |
| 126 | return None, False |
| 127 | |
| 128 | |
| 129 | def detect_cuda_version(): |
no test coverage detected