Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 25fc6fd

Browse files
committed
add dylib for windows
1 parent 835a654 commit 25fc6fd

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

engine/services/engine_service.cc

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ cpp::result<bool, std::string> EngineService::DownloadCuda(
467467
auto engine_path = file_manager_utils::GetCudaToolkitPath(engine);
468468
archive_utils::ExtractArchive(finishedTask.items[0].localPath.string(),
469469
engine_path.string());
470-
471470
try {
472471
std::filesystem::remove(finishedTask.items[0].localPath);
473472
} catch (std::exception& e) {
@@ -753,10 +752,19 @@ cpp::result<void, std::string> EngineService::LoadEngine(
753752
auto add_dll = [this](const std::string& e_type, const std::string& p) {
754753
auto ws = std::wstring(p.begin(), p.end());
755754
if (auto cookie = AddDllDirectory(ws.c_str()); cookie != 0) {
756-
LOG_INFO << "Added dll directory: " << p;
755+
CTL_DBG("Added dll directory: " << p);
757756
engines_[e_type].cookie = cookie;
758757
} else {
759-
LOG_WARN << "Could not add dll directory: " << p;
758+
CTL_WRN("Could not add dll directory: " << p);
759+
}
760+
761+
auto cuda_path = file_manager_utils::GetCudaToolkitPath(e_type);
762+
if (auto cuda_cookie = AddDllDirectory(cuda_path.c_str());
763+
cuda_cookie != 0) {
764+
CTL_DBG("Added cuda dll directory: " << p);
765+
engines_[e_type].cuda_cookie = cuda_cookie;
766+
} else {
767+
CTL_WRN("Could not add cuda dll directory: " << p);
760768
}
761769
};
762770

@@ -766,9 +774,14 @@ cpp::result<void, std::string> EngineService::LoadEngine(
766774
should_use_dll_search_path) {
767775
// Remove llamacpp dll directory
768776
if (!RemoveDllDirectory(engines_[kLlamaRepo].cookie)) {
769-
LOG_WARN << "Could not remove dll directory: " << kLlamaRepo;
777+
CTL_WRN("Could not remove dll directory: " << kLlamaRepo);
770778
} else {
771-
LOG_INFO << "Removed dll directory: " << kLlamaRepo;
779+
CTL_DBG("Removed dll directory: " << kLlamaRepo);
780+
}
781+
if (!RemoveDllDirectory(engines_[kLlamaRepo].cuda_cookie)) {
782+
CTL_WRN("Could not remove cuda dll directory: " << kLlamaRepo);
783+
} else {
784+
CTL_DBG("Removed cuda dll directory: " << kLlamaRepo);
772785
}
773786

774787
add_dll(ne, engine_dir_path.string());
@@ -783,7 +796,7 @@ cpp::result<void, std::string> EngineService::LoadEngine(
783796
std::make_unique<cortex_cpp::dylib>(engine_dir_path.string(), "engine");
784797

785798
} catch (const cortex_cpp::dylib::load_error& e) {
786-
LOG_ERROR << "Could not load engine: " << e.what();
799+
CTL_ERR("Could not load engine: " << e.what());
787800
engines_.erase(ne);
788801
return cpp::fail("Could not load engine " + ne + ": " + e.what());
789802
}
@@ -800,10 +813,10 @@ cpp::result<void, std::string> EngineService::LoadEngine(
800813
std::filesystem::path(config.logLlamaCppPath))
801814
.string());
802815
} else {
803-
LOG_WARN << "Method SetFileLogger is not supported yet";
816+
CTL_WRN("Method SetFileLogger is not supported yet");
804817
}
805818
}
806-
LOG_INFO << "Loaded engine: " << ne;
819+
CTL_DBG("Loaded engine: " << ne);
807820
return {};
808821
}
809822

@@ -817,13 +830,18 @@ cpp::result<void, std::string> EngineService::UnloadEngine(
817830
delete e;
818831
#if defined(_WIN32)
819832
if (!RemoveDllDirectory(engines_[ne].cookie)) {
820-
LOG_WARN << "Could not remove dll directory: " << ne;
833+
CTL_WRN("Could not remove dll directory: " << ne);
834+
} else {
835+
CTL_DBG("Removed dll directory: " << ne);
836+
}
837+
if (!RemoveDllDirectory(engines_[ne].cuda_cookie)) {
838+
CTL_WRN("Could not remove cuda dll directory: " << ne);
821839
} else {
822-
LOG_INFO << "Removed dll directory: " << ne;
840+
CTL_DBG("Removed cuda dll directory: " << ne);
823841
}
824842
#endif
825843
engines_.erase(ne);
826-
LOG_INFO << "Unloaded engine " + ne;
844+
CTL_DBG("Unloaded engine " + ne);
827845
return {};
828846
}
829847

engine/services/engine_service.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class EngineService {
7676
EngineV engine;
7777
#if defined(_WIN32)
7878
DLL_DIRECTORY_COOKIE cookie;
79+
DLL_DIRECTORY_COOKIE cuda_cookie;
7980
#endif
8081
};
8182

0 commit comments

Comments
 (0)