From 9eaf105ae8c9ded91df8a20dff96fe23897db95f Mon Sep 17 00:00:00 2001 From: Kawrakow Date: Thu, 26 Mar 2026 10:42:35 +0100 Subject: [PATCH] Print info when allocating large amounts of pinned host memory (#1517) --- ggml/src/ggml-cuda.cu | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ggml/src/ggml-cuda.cu b/ggml/src/ggml-cuda.cu index 205747e6..a3b0a418 100644 --- a/ggml/src/ggml-cuda.cu +++ b/ggml/src/ggml-cuda.cu @@ -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();