From 89a012658f2891c14758764e557f7dfe7fdfb8ed Mon Sep 17 00:00:00 2001 From: Clif Houck Date: Fri, 19 Jan 2024 12:05:14 -0600 Subject: [PATCH] Rearrange metric enablement, so that model metric reporter can proceed properly --- src/tritonserver.cc | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/tritonserver.cc b/src/tritonserver.cc index 272fd6cf1..a3523a98b 100644 --- a/src/tritonserver.cc +++ b/src/tritonserver.cc @@ -2330,6 +2330,25 @@ TRITONSERVER_ServerNew( tc::Metrics::SetMetricsInterval(loptions->MetricsInterval()); tc::Metrics::SetConfigMap(loptions->MetricsConfigMap()); } + +#ifdef TRITON_ENABLE_METRICS_GPU + if (loptions->Metrics() && loptions->GpuMetrics()) { + tc::Metrics::EnableGPUMetrics(); + } +#endif // TRITON_ENABLE_METRICS_GPU + +#ifdef TRITON_ENABLE_METRICS_CPU + if (loptions->Metrics() && loptions->CpuMetrics()) { + tc::Metrics::EnableCpuMetrics(); + } +#endif // TRITON_ENABLE_METRICS_CPU + + const bool poll_metrics = (loptions->GpuMetrics() || loptions->CpuMetrics()); + if (loptions->Metrics() && poll_metrics) { + // Start thread to poll enabled metrics periodically + tc::Metrics::StartPollingThreadSingleton(); + } + #endif // TRITON_ENABLE_METRICS lserver->SetId(loptions->ServerId()); @@ -2376,27 +2395,6 @@ TRITONSERVER_ServerNew( // Initialize server tc::Status status = lserver->Init(); -#ifdef TRITON_ENABLE_METRICS -#ifdef TRITON_ENABLE_METRICS_GPU - if (loptions->Metrics() && loptions->GpuMetrics()) { - tc::Metrics::EnableGPUMetrics(); - } -#endif // TRITON_ENABLE_METRICS_GPU - -#ifdef TRITON_ENABLE_METRICS_CPU - if (loptions->Metrics() && loptions->CpuMetrics()) { - tc::Metrics::EnableCpuMetrics(); - } -#endif // TRITON_ENABLE_METRICS_CPU - - const bool poll_metrics = (loptions->GpuMetrics() || loptions->CpuMetrics()); - if (loptions->Metrics() && poll_metrics) { - // Start thread to poll enabled metrics periodically - tc::Metrics::StartPollingThreadSingleton(); - } -#endif // TRITON_ENABLE_METRICS - - // Setup tritonserver options table std::vector options_headers; options_headers.emplace_back("Option");