Skip to content

Commit e6d62c9

Browse files
authored
Merge pull request #72 from tsisw/sakanaAI-issue
@FIR-1049 - llama.cpp crash after running model when llama-cli pick b…
2 parents 11b4019 + 6235f6d commit e6d62c9

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

ggml/src/ggml-tsavorite/ggml-tsavorite.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -718,21 +718,26 @@ static void ggml_tsavorite_free(struct ggml_backend_tsavorite_context *ctx) {
718718
// delay to allow any file operations to complete for runtime
719719

720720
GGML_TSAVORITE_LOG_INFO("Delaying tsi_finalize for 2 sec");
721-
sleep(2);
722-
tsi_finalize();
723-
GGML_TSAVORITE_LOG_INFO("End %s\n", __func__);
724-
tsirt::utils::TSIProfiler::finalize();
721+
if (runtime_initialized == true) {
722+
sleep(2);
723+
runtime_initialized = false;
724+
tsi_finalize();
725+
tsirt::utils::TSIProfiler::finalize();
726+
sleep(2);
727+
}
725728
std::cout << "\nOPU Profiling Results:" << std::endl;
726729
std::cout << tsirt::utils::TSIProfiler::getFormattedResults(
727730
/*truncateFuncNames*/ true)
728731
<< std::endl;
729-
sleep(2);
732+
GGML_TSAVORITE_LOG_INFO("End %s\n", __func__);
733+
return;
730734
}
731735

732736
void
733737
tsi_cleanup() {
734738
if (runtime_initialized != true)
735739
return;
740+
runtime_initialized = false;
736741
tsi_finalize();
737742
GGML_TSAVORITE_LOG_INFO("Start %s\n", __func__);
738743
tsirt::utils::TSIProfiler::finalize();

tools/main/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,7 @@ int main(int argc, char ** argv) {
10131013
common_perf_print(ctx, smpl);
10141014

10151015
common_sampler_free(smpl);
1016+
ggml_backend_cleanup();
10161017

10171018
llama_backend_free();
10181019

0 commit comments

Comments
 (0)