Re-evaluating device info when get closer to zero mem #153
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When GPU memory comes to its end GPUMemoryManager::GetInfo may report for available memory some value like 174MB and cudnnGetConvolutionForwardAlgorithm decides to take about 143MB out of it for better algorithm. Suddenly, cudaMalloc refuses to allocate 143MB out of the "last 174" and Caffe crashes. It has nothing to do with cache - I verified that no single deallocation happen before the OOM appears. So, the cache is empty. After debugging I found that Device Info values we maintain are diverging from reality when we get more and more allocations. Perhaps, due to cudaMalloc alignment or for some other reason. The fix updates the dev_info_ structure when we get allocation failure while calling new allocator try_allocate (as well as try_reserve). We use new try mechanism to ensure that convolution algorithm chooser does the right thing.