@@ -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) {
@@ -758,6 +757,15 @@ cpp::result<void, std::string> EngineService::LoadEngine(
758757 } else {
759758 LOG_WARN << " Could not add dll directory: " << p;
760759 }
760+
761+ auto cuda_path = file_manager_utils::GetCudaToolkitPath (e_type);
762+ if (auto cuda_cookie = AddDllDirectory (cuda_path.string ());
763+ cuda_cookie != 0 ) {
764+ LOG_INFO << " Added cuda dll directory: " << p;
765+ engines_[e_type].cuda_cookie = cuda_cookie;
766+ } else {
767+ LOG_WARN << " Could not add cuda dll directory: " << p;
768+ }
761769 };
762770
763771 if (bool should_use_dll_search_path = !(getenv (" ENGINE_PATH" ));
@@ -770,6 +778,11 @@ cpp::result<void, std::string> EngineService::LoadEngine(
770778 } else {
771779 LOG_INFO << " Removed dll directory: " << kLlamaRepo ;
772780 }
781+ if (!RemoveDllDirectory (engines_[kLlamaRepo ].cuda_cookie )) {
782+ LOG_WARN << " Could not remove cuda dll directory: " << kLlamaRepo ;
783+ } else {
784+ LOG_INFO << " Removed cuda dll directory: " << kLlamaRepo ;
785+ }
773786
774787 add_dll (ne, engine_dir_path.string ());
775788 } else if (IsEngineLoaded (kTrtLlmRepo ) && ne == kLlamaRepo ) {
@@ -821,6 +834,11 @@ cpp::result<void, std::string> EngineService::UnloadEngine(
821834 } else {
822835 LOG_INFO << " Removed dll directory: " << ne;
823836 }
837+ if (!RemoveDllDirectory (engines_[ne].cuda_cookie )) {
838+ LOG_WARN << " Could not remove cuda dll directory: " << ne;
839+ } else {
840+ LOG_INFO << " Removed cuda dll directory: " << ne;
841+ }
824842#endif
825843 engines_.erase (ne);
826844 LOG_INFO << " Unloaded engine " + ne;
0 commit comments