Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ggml-opencl : store GPU buffer in ggml_tensor::extra #2994

Merged
merged 1 commit into from
Sep 4, 2023
Merged

Conversation

slaren
Copy link
Collaborator

@slaren slaren commented Sep 3, 2023

ggml-opencl currently stores the GPU buffer in ggml_tensor::data, and after the GGUF changes this will result in a memory leak when not using mmap, as the address of the CPU buffer is lost after the call to ggml_cl_transform_tensor:

llama.cpp/llama.cpp

Lines 1516 to 1523 in 47068e5

#elif defined(GGML_USE_CLBLAST)
case GGML_BACKEND_GPU:
ggml_cl_transform_tensor(cur->data, cur);
if (!use_mmap) {
free(cur->data);
}
break;
#endif

This change solves that issue and a possible interaction with ggml-alloc if the opencl buffer falls within the measure buffer memory range by storing the GPU buffer in ggml_tensor::extra instead.

Fixes #2993

@slaren slaren merged commit bd33e5a into master Sep 4, 2023
@slaren slaren deleted the opencl-extra branch September 4, 2023 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

llama.cpp/ggml-alloc.c:230: alloc->n_free_blocks < MAX_FREE_BLOCKS && "out of free blocks"
2 participants