Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
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
5 changes: 4 additions & 1 deletion engine/controllers/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ namespace inferences {
server::server(std::shared_ptr<services::InferenceService> inference_service)
: inference_svc_(inference_service) {
#if defined(_WIN32)
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
if (bool should_use_dll_search_path = !(getenv("ENGINE_PATH"));
should_use_dll_search_path) {
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
}
#endif
};

Expand Down
37 changes: 22 additions & 15 deletions engine/services/inference_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,23 @@ InferResult InferenceService::LoadModel(
}
};

if (IsEngineLoaded(kLlamaRepo) && ne == kTrtLlmRepo) {
// Remove llamacpp dll directory
if (!RemoveDllDirectory(engines_[kLlamaRepo].cookie)) {
LOG_WARN << "Could not remove dll directory: " << kLlamaRepo;
if (bool should_use_dll_search_path = !(getenv("ENGINE_PATH"));
should_use_dll_search_path) {
if (IsEngineLoaded(kLlamaRepo) && ne == kTrtLlmRepo &&
should_use_dll_search_path) {
// Remove llamacpp dll directory
if (!RemoveDllDirectory(engines_[kLlamaRepo].cookie)) {
LOG_WARN << "Could not remove dll directory: " << kLlamaRepo;
} else {
LOG_INFO << "Removed dll directory: " << kLlamaRepo;
}

add_dll(ne, abs_path);
} else if (IsEngineLoaded(kTrtLlmRepo) && ne == kLlamaRepo) {
// Do nothing
} else {
LOG_INFO << "Removed dll directory: " << kLlamaRepo;
add_dll(ne, abs_path);
}

add_dll(ne, abs_path);
} else if (IsEngineLoaded(kTrtLlmRepo) && ne == kLlamaRepo) {
// Do nothing
} else {
add_dll(ne, abs_path);
}
#endif
engines_[ne].dl = std::make_unique<cortex_cpp::dylib>(abs_path, "engine");
Expand Down Expand Up @@ -366,10 +370,13 @@ InferResult InferenceService::UnloadEngine(
EngineI* e = std::get<EngineI*>(engines_[ne].engine);
delete e;
#if defined(_WIN32)
if (!RemoveDllDirectory(engines_[ne].cookie)) {
LOG_WARN << "Could not remove dll directory: " << ne;
} else {
LOG_INFO << "Removed dll directory: " << ne;
if (bool should_use_dll_search_path = !(getenv("ENGINE_PATH"));
should_use_dll_search_path) {
if (!RemoveDllDirectory(engines_[ne].cookie)) {
LOG_WARN << "Could not remove dll directory: " << ne;
} else {
LOG_INFO << "Removed dll directory: " << ne;
}
}
#endif
engines_.erase(ne);
Expand Down
Loading