diff --git a/paddle/fluid/memory/detail/system_allocator.cc b/paddle/fluid/memory/detail/system_allocator.cc index 2463fdf4836c07a23443573afda77f2518050b71..bb6862990aaeda844dac7b60eea6678ec7f91ebf 100644 --- a/paddle/fluid/memory/detail/system_allocator.cc +++ b/paddle/fluid/memory/detail/system_allocator.cc @@ -131,7 +131,12 @@ void* CUDAPinnedAllocator::Alloc(size_t& index, size_t size) { size_t usable = paddle::platform::CUDAPinnedMaxAllocSize() - cuda_pinnd_alloc_size_; - if (size > usable) return nullptr; + if (size > usable) { + LOG(WARNING) << "Cannot malloc " << size / 1024.0 / 1024.0 + << " MB pinned memory." + << ", available " << usable / 1024.0 / 1024.0 << " MB"; + return nullptr; + } void* p; // PINNED memory is visible to all CUDA contexts. @@ -141,6 +146,9 @@ void* CUDAPinnedAllocator::Alloc(size_t& index, size_t size) { index = 1; // PINNED memory cuda_pinnd_alloc_size_ += size; return p; + } else { + LOG(WARNING) << "cudaMallocHost failed."; + return nullptr; } return nullptr; diff --git a/paddle/fluid/memory/memory.cc b/paddle/fluid/memory/memory.cc index 7b459fe4d0bde51a2ae6693b849dc4f9fa0b4f89..dc6c362728b86367c4dd6eb881d8647ae71a9cff 100644 --- a/paddle/fluid/memory/memory.cc +++ b/paddle/fluid/memory/memory.cc @@ -133,11 +133,10 @@ void* Alloc(platform::CUDAPinnedPlace place, auto* buddy_allocator = GetCUDAPinnedBuddyAllocator(); void* ptr = buddy_allocator->Alloc(size); - // if (ptr == nullptr) { - // LOG(WARNING) << "Cannot allocate " << size << " bytes in CUDAPinnedPlace - // " - // << ", available " << avail << " bytes" - // } + if (ptr == nullptr) { + LOG(WARNING) << "cudaMallocHost Cannot allocate " << size + << " bytes in CUDAPinnedPlace"; + } return ptr; } diff --git a/paddle/fluid/platform/cpu_info.cc b/paddle/fluid/platform/cpu_info.cc index d44f1cadd2e73f27d653a73b531737bc5e1f650e..4fc9aae8e36e9b43d65fab0b92ec3a2549057128 100644 --- a/paddle/fluid/platform/cpu_info.cc +++ b/paddle/fluid/platform/cpu_info.cc @@ -27,9 +27,10 @@ DEFINE_double(fraction_of_cpu_memory_to_use, 1, "Default use 100% of CPU memory for PaddlePaddle," "reserve the rest for page tables, etc"); -DEFINE_double(fraction_of_cuda_pinned_memory_to_use, 0.5, - "Default use 100% of CPU memory for PaddlePaddle," - "reserve the rest for page tables, etc"); +DEFINE_double( + fraction_of_cuda_pinned_memory_to_use, 0.5, + "Default use 50% of CPU memory as the pinned_memory for PaddlePaddle," + "reserve the rest for page tables, etc"); namespace paddle { namespace platform { @@ -78,7 +79,7 @@ size_t CUDAPinnedMinChunkSize() { } size_t CUDAPinnedMaxChunkSize() { - // Allow to allocate the maximum chunk size is roughly 0.39% of CUDA_PINNED + // Allow to allocate the maximum chunk size is roughly 1/256 of CUDA_PINNED // memory. return CUDAPinnedMaxAllocSize() / 256; }