diff --git a/common/waifu2x.cpp b/common/waifu2x.cpp index 6e22a1c..d2bb3c9 100644 --- a/common/waifu2x.cpp +++ b/common/waifu2x.cpp @@ -522,8 +522,14 @@ void Waifu2x::quit_liblary() { g_ConvCcuDNNAlgorithm.Save(); g_DeconvCcuDNNAlgorithm.Save(); + + caffe::GlobalFinalize(); } +void Waifu2x::quit_thread_liblary() +{ + caffe::ThreadFinalize(); +} Waifu2x::Waifu2x() : mIsInited(false), mNoiseLevel(0), mIsCuda(false), mOutputBlock(nullptr), mOutputBlockSize(0), mGPUNo(0) {} diff --git a/common/waifu2x.h b/common/waifu2x.h index eecb5be..6d93080 100644 --- a/common/waifu2x.h +++ b/common/waifu2x.h @@ -125,6 +125,7 @@ public: static void init_liblary(int argc, char** argv); static void quit_liblary(); + static void quit_thread_liblary(); // mode: noise or scale or noise_scale or auto_scale // process: cpu or gpu or cudnn diff --git a/waifu2x-caffe-dll/Source.cpp b/waifu2x-caffe-dll/Source.cpp index b532595..bb4a2ff 100644 --- a/waifu2x-caffe-dll/Source.cpp +++ b/waifu2x-caffe-dll/Source.cpp @@ -85,3 +85,9 @@ void Waifu2xDestory(void *waifu2xObj) delete obj; } } + +__declspec(dllexport) +void Waifu2xGlobalDestroy() +{ + Waifu2x::quit_liblary(); +} diff --git a/waifu2x-caffe-gui/MainDialog.cpp b/waifu2x-caffe-gui/MainDialog.cpp index 3c8a4b1..04691a0 100644 --- a/waifu2x-caffe-gui/MainDialog.cpp +++ b/waifu2x-caffe-gui/MainDialog.cpp @@ -804,6 +804,8 @@ void DialogEvent::ProcessWaifu2x() } } + Waifu2x::quit_thread_liblary(); + const auto ProcessEndTime = std::chrono::system_clock::now(); cuDNNCheckTime = cuDNNCheckEndTime - cuDNNCheckStartTime;