Print info when allocating large amounts of pinned host memory (#1517)
This commit is contained in:
parent
aa7fdb3259
commit
9eaf105ae8
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue