File tree 2 files changed +10
-8
lines changed
2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ void* GPUAllocator::Alloc(size_t& index, size_t size) {
83
83
paddle::platform::GpuMemoryUsage (available, capacity);
84
84
85
85
// Reserve memory for page tables, etc.
86
- size_t reserving = capacity - paddle::platform::GpuMaxAllocSize ();
86
+ size_t reserving = 0.05 * capacity + paddle::platform::GpuMinChunkSize ();
87
87
size_t usable = available > reserving ? available - reserving : 0 ;
88
88
89
89
// If remaining size no less than expected size, using general
Original file line number Diff line number Diff line change @@ -64,19 +64,21 @@ BuddyAllocator* GetGPUBuddyAllocator(int gpu_id) {
64
64
int gpu_num = platform::GetCUDADeviceCount ();
65
65
as = new BuddyAllocator*[gpu_num];
66
66
for (int gpu = 0 ; gpu < gpu_num; gpu++) {
67
- platform::SetDeviceId (gpu);
68
- as[gpu] = new BuddyAllocator (new detail::GPUAllocator,
69
- platform::GpuMinChunkSize (),
70
- platform::GpuMaxChunkSize ());
67
+ as[gpu] = nullptr ;
71
68
}
69
+ }
70
+ platform::SetDeviceId (gpu_id);
71
+ if (!as[gpu_id]) {
72
+ as[gpu_id] = new BuddyAllocator (new detail::GPUAllocator,
73
+ platform::GpuMinChunkSize (),
74
+ platform::GpuMaxChunkSize ());
72
75
VLOG (10 ) << " \n\n NOTE: each GPU device use "
73
76
<< FLAGS_fraction_of_gpu_memory_to_use * 100
74
77
<< " % of GPU memory.\n "
75
- << " You can set environment variable '"
76
- << platform:: kEnvFractionGpuMemoryToUse
78
+ << " You can set GFlags environment variable '"
79
+ << " FLAGS_fraction_of_gpu_memory_to_use "
77
80
<< " ' to change the fraction of GPU usage.\n\n " ;
78
81
}
79
- platform::SetDeviceId (gpu_id);
80
82
return as[gpu_id];
81
83
}
82
84
You can’t perform that action at this time.
0 commit comments