diff --git a/ggml/src/ggml-cuda.cu b/ggml/src/ggml-cuda.cu index 3cd505a9..3bd8f1b0 100644 --- a/ggml/src/ggml-cuda.cu +++ b/ggml/src/ggml-cuda.cu @@ -544,6 +544,10 @@ ggml_backend_cuda_context::~ggml_backend_cuda_context() { CUBLAS_CHECK(cublasDestroy(cublas_handles[i])); } } + auto info = const_cast(&ggml_cuda_info()); + if (info->all_ctx[device] == this) { + info->all_ctx[device] = nullptr; + } }