Print info when allocating large amounts of pinned host memory (#1517)

This commit is contained in:
Kawrakow 2026-03-26 10:42:35 +01:00 committed by GitHub
parent aa7fdb3259
commit 9eaf105ae8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 0 deletions

View File

@ -1261,9 +1261,19 @@ static void * ggml_cuda_host_malloc(size_t size) {
if (getenv("GGML_CUDA_NO_PINNED") != nullptr) {
return nullptr;
}
constexpr double k_warn_limit = 8.0;
void * ptr = nullptr;
double size_GiB = size/(1024.*1024.*1024.);
auto tim1 = ggml_time_us();
if (size_GiB > k_warn_limit) {
GGML_CUDA_LOG_INFO("Allocating %.2f GiB of pinned host memory, this can take a while...\n", size_GiB);
}
cudaError_t err = cudaMallocHost((void **) &ptr, size);
if (size_GiB > k_warn_limit) {
auto tim2 = ggml_time_us();
GGML_CUDA_LOG_INFO(" done allocating %.2f GiB in %.1f ms\n", size_GiB, 1e-3*(tim2-tim1));
}
if (err != cudaSuccess) {
// clear the error
cudaGetLastError();