|
|
|
@ -14,8 +14,9 @@ limitations under the License. */
|
|
|
|
|
|
|
|
|
|
#include "paddle/fluid/platform/gpu_info.h"
|
|
|
|
|
|
|
|
|
|
#include "gflags/gflags.h"
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
|
|
#include "gflags/gflags.h"
|
|
|
|
|
#include "paddle/fluid/platform/enforce.h"
|
|
|
|
|
|
|
|
|
|
DEFINE_double(fraction_of_gpu_memory_to_use, 0.92,
|
|
|
|
@ -77,8 +78,8 @@ void SetDeviceId(int id) {
|
|
|
|
|
"cudaSetDevice failed in paddle::platform::SetDeviceId");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GpuMemoryUsage(size_t &available, size_t &total) {
|
|
|
|
|
PADDLE_ENFORCE(cudaMemGetInfo(&available, &total),
|
|
|
|
|
void GpuMemoryUsage(size_t *available, size_t *total) {
|
|
|
|
|
PADDLE_ENFORCE(cudaMemGetInfo(available, total),
|
|
|
|
|
"cudaMemGetInfo failed in paddle::platform::GetMemoryUsage");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -86,7 +87,7 @@ size_t GpuMaxAllocSize() {
|
|
|
|
|
size_t total = 0;
|
|
|
|
|
size_t available = 0;
|
|
|
|
|
|
|
|
|
|
GpuMemoryUsage(available, total);
|
|
|
|
|
GpuMemoryUsage(&available, &total);
|
|
|
|
|
|
|
|
|
|
// Reserve the rest for page tables, etc.
|
|
|
|
|
return static_cast<size_t>(total * FLAGS_fraction_of_gpu_memory_to_use);
|
|
|
|
@ -101,7 +102,7 @@ size_t GpuMaxChunkSize() {
|
|
|
|
|
size_t total = 0;
|
|
|
|
|
size_t available = 0;
|
|
|
|
|
|
|
|
|
|
GpuMemoryUsage(available, total);
|
|
|
|
|
GpuMemoryUsage(&available, &total);
|
|
|
|
|
VLOG(10) << "GPU Usage " << available / 1024 / 1024 << "M/"
|
|
|
|
|
<< total / 1024 / 1024 << "M";
|
|
|
|
|
size_t reserving = static_cast<size_t>(0.05 * total);
|
|
|
|
|