The GPU memory allocation policy is not reasonable
Created by: QiJune
Here is the method caculating GpuMaxChunkSize.
size_t GpuMaxChunkSize() {
size_t total = 0;
size_t available = 0;
GpuMemoryUsage(available, total);
// Reserving the rest memory for page tables, etc.
size_t reserving = (1 - FLAGS_fraction_of_gpu_memory_to_use) * total;
// If available less than minimum chunk size, no usable memory exists.
available = std::max(available, GpuMinChunkSize()) - GpuMinChunkSize();
// If available less than reserving, no usable memory exists.
size_t usable = std::max(available, reserving) - reserving;
return usable;
}
If we set certain fraction_of_gpu_memory_to_use, we must ensure available GPU memory is larger than reserving memory under this policy. It will always fail if we run many unit tests in parallel under this policy. For example, we set FLAGS_fraction_of_gpu_memory_to_use=0.2. The first unit test occupy 0.2 GPU memory. When the second unit test comes in, the available GPU memory is 0.8, but the reserving memory is also 0.8. So, it will failed. In fact, we should ensure our allocating memory is less than available memory. So, we need to change the allocation policy.