提交 d066b07f 编写于 作者: Q QI JUN 提交者: Yu Yang

change GPU memory allocating policy (#6159)

* change GPU memory allocating policy

* fix potential overflow bug
上级 e50f3570
......@@ -75,15 +75,19 @@ size_t GpuMaxChunkSize() {
GpuMemoryUsage(available, total);
// Reserving the rest memory for page tables, etc.
size_t reserving = (1 - FLAGS_fraction_of_gpu_memory_to_use) * total;
size_t reserving = 0.05 * total;
// If available less than minimum chunk size, no usable memory exists.
available = std::max(available, GpuMinChunkSize()) - GpuMinChunkSize();
available =
std::max(std::max(available, GpuMinChunkSize()) - GpuMinChunkSize(),
reserving) -
reserving;
// If available less than reserving, no usable memory exists.
size_t usable = std::max(available, reserving) - reserving;
size_t allocating = FLAGS_fraction_of_gpu_memory_to_use * total;
return usable;
PADDLE_ENFORCE_LT(allocating, available);
return allocating;
}
void GpuMemcpyAsync(void *dst, const void *src, size_t count,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册