Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add repo agents to console log #2503

Merged
merged 1 commit into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/backends/backend/triton_backend_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,11 @@ TritonBackendManager::BackendState(
TritonBackendManager& singleton_manager = Singleton();
std::lock_guard<std::mutex> lock(singleton_manager.mu_);

auto backend_map = singleton_manager.backend_map_;

std::unique_ptr<std::unordered_map<std::string, std::vector<std::string>>>
backend_state_map(
new std::unordered_map<std::string, std::vector<std::string>>);
for (const auto& backend_pair : backend_map) {
auto libpath = backend_pair.first;
for (const auto& backend_pair : singleton_manager.backend_map_) {
auto& libpath = backend_pair.first;
auto backend = backend_pair.second.lock();

if (backend != nullptr) {
Expand Down
23 changes: 22 additions & 1 deletion src/core/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "src/core/model_config_utils.h"
#include "src/core/model_repository_manager.h"
#include "src/core/pinned_memory_manager.h"
#include "src/core/triton_repo_agent.h"
#include "triton/common/table_printer.h"

#ifdef TRITON_ENABLE_GPU
Expand Down Expand Up @@ -467,11 +468,31 @@ InferenceServer::UnloadModel(const std::string& model_name)
Status
InferenceServer::PrintBackendAndModelSummary()
{
// Repository Agents Summary
std::vector<std::string> repoagent_headers;
repoagent_headers.emplace_back("Repository Agent");
repoagent_headers.emplace_back("Path");

triton::common::TablePrinter repoagents_table(repoagent_headers);

std::unique_ptr<std::unordered_map<std::string, std::string>>
repoagent_state;
RETURN_IF_ERROR(TritonRepoAgentManager::AgentState(&repoagent_state));

for (const auto& repoagent_pair : *repoagent_state) {
std::vector<std::string> repoagent_record;
repoagent_record.emplace_back(repoagent_pair.first);
repoagent_record.emplace_back(repoagent_pair.second);
repoagents_table.InsertRow(repoagent_record);
}
std::string repoagents_table_string = repoagents_table.PrintTable();
LOG_INFO << repoagents_table_string;

// Backends Summary
std::vector<std::string> backend_headers;
backend_headers.emplace_back("Backend");
backend_headers.emplace_back("Config");
backend_headers.emplace_back("Path");
backend_headers.emplace_back("Config");

triton::common::TablePrinter backends_table(backend_headers);

Expand Down
42 changes: 34 additions & 8 deletions src/core/triton_repo_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,9 @@ TritonRepoAgentManager::CreateAgent(
auto& singleton_manager = Singleton();
std::lock_guard<std::mutex> lock(singleton_manager.mu_);

// Get the path to the backend shared library. Search path is
// model directory, global agent directory.
// FIXME expose global path as Triton option
// Get the path to the agent shared library. Search path is model
// directory, global agent directory. FIXME expose global path as
// Triton option
const std::vector<std::string> search_paths = {
model_dir, singleton_manager.global_search_path_};

Expand All @@ -398,10 +398,10 @@ TritonRepoAgentManager::CreateAgent(
const auto& itr = singleton_manager.agent_map_.find(libpath);
if (itr != singleton_manager.agent_map_.end()) {
// Found in map. If the weak_ptr is still valid that means that
// there are other models using the backend and we just reuse that
// same backend. If the weak_ptr is not valid then backend has
// been unloaded so we need to remove the weak_ptr from the map
// and create the backend again.
// there are other models using the agent and we just reuse that
// same agent. If the weak_ptr is not valid then agent has been
// unloaded so we need to remove the weak_ptr from the map and
// create the agent again.
*agent = itr->second.lock();
if (*agent != nullptr) {
return Status::Success;
Expand All @@ -415,6 +415,32 @@ TritonRepoAgentManager::CreateAgent(
return Status::Success;
}

Status
TritonRepoAgentManager::AgentState(
std::unique_ptr<
std::unordered_map<std::string, std::string>>*
agent_state)
{
auto& singleton_manager = Singleton();
std::lock_guard<std::mutex> lock(singleton_manager.mu_);

std::unique_ptr<std::unordered_map<std::string, std::string>>
agent_state_map(
new std::unordered_map<std::string, std::string>);
for (const auto& agent_pair : singleton_manager.agent_map_) {
auto& libpath = agent_pair.first;
auto agent = agent_pair.second.lock();

if (agent != nullptr) {
agent_state_map->insert({agent->Name(), libpath});
}
}

*agent_state = std::move(agent_state_map);

return Status::Success;
}

extern "C" {

TRITONSERVER_Error*
Expand Down Expand Up @@ -541,4 +567,4 @@ TRITONREPOAGENT_SetState(TRITONREPOAGENT_Agent* agent, void* state)

} // extern C

}} // namespace nvidia::inferenceserver
}} // namespace nvidia::inferenceserver
5 changes: 5 additions & 0 deletions src/core/triton_repo_agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ class TritonRepoAgentManager {
const std::string& model_dir, const std::string& agent_name,
std::shared_ptr<TritonRepoAgent>* agent);

static Status AgentState(
std::unique_ptr<
std::unordered_map<std::string, std::string>>*
agent_state);

private:
DISALLOW_COPY_AND_ASSIGN(TritonRepoAgentManager);

Expand Down