|
|
|
@ -27,6 +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");
|
|
|
|
|
|
|
|
|
|
namespace paddle {
|
|
|
|
|
namespace platform {
|
|
|
|
|
|
|
|
|
@ -62,5 +66,22 @@ size_t CpuMaxChunkSize() {
|
|
|
|
|
return CpuMaxAllocSize() / 32;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t CUDAPinnedMaxAllocSize() {
|
|
|
|
|
// For distributed systems, it requires configuring and limiting
|
|
|
|
|
// the fraction of memory to use.
|
|
|
|
|
return FLAGS_fraction_of_cuda_pinned_memory_to_use * CpuTotalPhysicalMemory();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t CUDAPinnedMinChunkSize() {
|
|
|
|
|
// Allow to allocate the minimum chunk size is 64 KB.
|
|
|
|
|
return 1 << 16;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t CUDAPinnedMaxChunkSize() {
|
|
|
|
|
// Allow to allocate the maximum chunk size is roughly 0.39% of CUDA_PINNED
|
|
|
|
|
// memory.
|
|
|
|
|
return CUDAPinnedMaxAllocSize() / 256;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace platform
|
|
|
|
|
} // namespace paddle
|
|
|
|
|