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

fix: only set dll search path if don't use ENGINE_PATH #1557

Merged
merged 1 commit into from
Oct 28, 2024
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