@@ -28,9 +28,15 @@ DEFINE_double(fraction_of_cpu_memory_to_use, 1,
2828 " Default use 100% of CPU memory for PaddlePaddle,"
2929 " reserve the rest for page tables, etc" );
3030
31- DEFINE_uint64 (
32- initial_cpu_memory_in_mb, 500 ,
33- " Default initial 500MB of CPU memory for PaddlePaddle, in MD unit." );
31+ DEFINE_uint64 (initial_cpu_memory_in_mb,
32+ #ifdef PADDLE_WITH_MKLDNN
33+ /* Aligned with mozga-intel, MKLDNN need at least 5000 MB
34+ * to obtain the best performance*/
35+ 5000 ,
36+ #else
37+ 500 ,
38+ #endif
39+ " Initial CPU memory for PaddlePaddle, in MD unit." );
3440
3541DEFINE_double (
3642 fraction_of_cuda_pinned_memory_to_use, 0.5 ,
@@ -59,10 +65,7 @@ inline size_t CpuTotalPhysicalMemory() {
5965size_t CpuMaxAllocSize () {
6066 // For distributed systems, it requires configuring and limiting
6167 // the fraction of memory to use.
62- return std::min (
63- static_cast <size_t >(FLAGS_fraction_of_cpu_memory_to_use *
64- CpuTotalPhysicalMemory ()),
65- static_cast <size_t >(FLAGS_initial_cpu_memory_in_mb * 1 << 20 ));
68+ return FLAGS_fraction_of_cpu_memory_to_use * CpuTotalPhysicalMemory ();
6669}
6770
6871size_t CpuMinChunkSize () {
@@ -71,8 +74,11 @@ size_t CpuMinChunkSize() {
7174}
7275
7376size_t CpuMaxChunkSize () {
74- // Allow to allocate the maximum chunk size is roughly 3% of CPU memory.
75- return CpuMaxAllocSize () / 32 ;
77+ // Allow to allocate the maximum chunk size is roughly 3% of CPU memory,
78+ // or the initial_cpu_memory_in_mb.
79+ return std::min (
80+ static_cast <size_t >(CpuMaxAllocSize () / 32 ),
81+ static_cast <size_t >(FLAGS_initial_cpu_memory_in_mb * 1 << 20 ));
7682}
7783
7884size_t CUDAPinnedMaxAllocSize () {
0 commit comments