Repository navigation
Don't empty the CUDA cache inside match() - #154
Open
ducha-aiki wants to merge 1 commit into
Open
ducha-aiki wants to merge 1 commit into
ducha-aiki wants to merge 1 commit into
Conversation
match() emptied the CUDA cache before the upsampled pass, so every call re-allocated the upsample activations and the ~3 GB KDE buffers of the following sample() from the driver. Outputs are unchanged; match()+sample() is 1.4-1.5x faster on an RTX 4090. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

RegressionMatcher.match()callstorch.cuda.empty_cache()between the coarse and the upsampled pass whenever it is given paths or PIL images (the default usage). PyTorch's caching allocator would otherwise reuse the blocks freed by the coarse pass. Returning them to the driver means every call payscudaFree/cudaMallocagain for the upsampled pass and, mostly, for the ~3 GBcdistbuffers of the KDE in thesample()call that usually follows.This PR removes that call. Outputs are unchanged. Callers that share the GPU with other processes can still call
torch.cuda.empty_cache()themselves.Measurements. RTX 4090, torch 2.14.0 + CUDA 13.0,
roma_outdoor(device)defaults (560/864, symmetric),match(path_A, path_B)followed bysample(warp, certainty, num=10000). 100 outdoor pairs (IMC 2021 PhotoTourism, reichstag),torch.manual_seed(0), mean over pairs 6–100, two repeats each:match()mssample()msmainfor all 100 pairs, and across repeats.torch==2.11.0.Written by Claude (Opus 5.5) on behalf of @ducha-aiki