|
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | 15 | from typing import List, Union, Optional |
16 | | -import sys |
| 16 | +import os, sys |
17 | 17 | from model_analyzer.constants import LOGGER_NAME, PA_ERROR_LOG_FILENAME |
18 | 18 | from .model_manager import ModelManager |
19 | 19 | from .result.result_manager import ResultManager |
@@ -126,17 +126,9 @@ def profile(self, client: TritonClient, gpus: List[GPUDevice], mode: str, |
126 | 126 | if not self._config.skip_summary_reports: |
127 | 127 | self._create_summary_tables(verbose) |
128 | 128 | self._create_summary_reports(mode) |
| 129 | + self._create_detailed_reports() |
129 | 130 |
|
130 | | - # TODO-TMA-650: Detailed reporting not supported for multi-model |
131 | | - if not self._config.run_config_profile_models_concurrently_enable: |
132 | | - for model in self._config.profile_models: |
133 | | - logger.info( |
134 | | - self._get_report_command_help_string( |
135 | | - model.model_name())) |
136 | | - |
137 | | - if self._metrics_manager.encountered_perf_analyzer_error(): |
138 | | - logger.warning(f"Perf Analyzer encountered an error when profiling one or more configurations. " \ |
139 | | - f"See {self._config.export_path}/{PA_ERROR_LOG_FILENAME} for further details.\n") |
| 131 | + self._check_for_perf_analyzer_errors() |
140 | 132 |
|
141 | 133 | def report(self, mode: str) -> None: |
142 | 134 | """ |
@@ -280,18 +272,28 @@ def _get_num_profiled_configs(self): |
280 | 272 | ]) |
281 | 273 |
|
282 | 274 | def _get_report_command_help_string(self, model_name: str) -> str: |
283 | | - top_3_model_config_names = self._get_top_n_model_config_names( |
284 | | - n=3, model_name=model_name) |
| 275 | + top_n_model_config_names = self._get_top_n_model_config_names( |
| 276 | + n=self._config.num_configs_per_model, model_name=model_name) |
285 | 277 | return ( |
286 | 278 | f'To generate detailed reports for the ' |
287 | | - f'{len(top_3_model_config_names)} best {model_name} configurations, run ' |
288 | | - f'`{self._get_report_command_string(top_3_model_config_names)}`') |
| 279 | + f'{len(top_n_model_config_names)} best {model_name} configurations, run ' |
| 280 | + f'`{self._get_report_command_string(top_n_model_config_names)}`') |
| 281 | + |
| 282 | + def _run_report_command(self, model_name: str) -> None: |
| 283 | + top_n_model_config_names = self._get_top_n_model_config_names( |
| 284 | + n=self._config.num_configs_per_model, model_name=model_name) |
| 285 | + top_n_string = ','.join(top_n_model_config_names) |
| 286 | + logger.info( |
| 287 | + f'Generating detailed reports for the best configurations {top_n_string}:' |
| 288 | + ) |
| 289 | + os.system( |
| 290 | + f'{self._get_report_command_string(top_n_model_config_names)}') |
289 | 291 |
|
290 | 292 | def _get_report_command_string(self, |
291 | | - top_3_model_config_names: List[str]) -> str: |
| 293 | + top_n_model_config_names: List[str]) -> str: |
292 | 294 | report_command_string = (f'model-analyzer report ' |
293 | 295 | f'--report-model-configs ' |
294 | | - f'{",".join(top_3_model_config_names)}') |
| 296 | + f'{",".join(top_n_model_config_names)}') |
295 | 297 |
|
296 | 298 | if self._config.export_path is not None: |
297 | 299 | report_command_string += (f' --export-path ' |
@@ -336,3 +338,19 @@ def _multiple_models_in_report_model_config(self) -> bool: |
336 | 338 | ] |
337 | 339 |
|
338 | 340 | return len(set(model_names)) > 1 |
| 341 | + |
| 342 | + def _check_for_perf_analyzer_errors(self) -> None: |
| 343 | + if self._metrics_manager.encountered_perf_analyzer_error(): |
| 344 | + logger.warning(f"Perf Analyzer encountered an error when profiling one or more configurations. " \ |
| 345 | + f"See {self._config.export_path}/{PA_ERROR_LOG_FILENAME} for further details.\n") |
| 346 | + |
| 347 | + def _create_detailed_reports(self) -> None: |
| 348 | + # TODO-TMA-650: Detailed reporting not supported for multi-model |
| 349 | + if not self._config.run_config_profile_models_concurrently_enable: |
| 350 | + for model in self._config.profile_models: |
| 351 | + if not self._config.skip_detailed_reports: |
| 352 | + self._run_report_command(model.model_name()) |
| 353 | + else: |
| 354 | + logger.info( |
| 355 | + self._get_report_command_help_string( |
| 356 | + model.model_name())) |
0 commit comments