Initialize model cache and load models.
(self)
| 116 | self.results: List[BenchmarkResult] = [] |
| 117 | |
| 118 | def setup(self): |
| 119 | """Initialize model cache and load models.""" |
| 120 | print("Setting up benchmark environment...") |
| 121 | |
| 122 | # Import here to avoid loading at import time |
| 123 | from questions.inference_server.model_cache import ModelCache |
| 124 | |
| 125 | self.model_cache = ModelCache() |
| 126 | |
| 127 | # Force garbage collection |
| 128 | gc.collect() |
| 129 | if torch.cuda.is_available(): |
| 130 | torch.cuda.empty_cache() |
| 131 | torch.cuda.synchronize() |
| 132 | |
| 133 | print(f" Device: {'CUDA' if torch.cuda.is_available() else 'CPU'}") |
| 134 | if torch.cuda.is_available(): |
| 135 | print(f" GPU: {torch.cuda.get_device_name(0)}") |
| 136 | print(f" GPU Memory: {torch.cuda.get_device_properties(0).total_memory / 1e9:.1f} GB") |
| 137 | print() |
| 138 | |
| 139 | def get_memory_usage(self) -> float: |
| 140 | """Get current GPU memory usage in MB.""" |
no test coverage detected