提交 2514d70e 编写于 作者: C chengduoZH

follow comments

上级 ffa63974
......@@ -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;
......
......@@ -133,11 +133,10 @@ void* Alloc<platform::CUDAPinnedPlace>(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;
}
......
......@@ -27,8 +27,9 @@ 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,"
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 {
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册