Fix CUDA memory buildup across files in ASR batch inference demo - #446
Closed
Ammar Hashmi (ammar-iitm) wants to merge 1 commit into
Closed
Ammar Hashmi (ammar-iitm) wants to merge 1 commit into
Ammar Hashmi (ammar-iitm) wants to merge 1 commit into
Conversation
transcribe_batch() held onto inputs/output_ids (including the KV cache) until the next loop iteration reassigned them, letting the CUDA caching allocator accumulate fragmented, cached-but-idle memory across files. On a 24GB GPU this pushed a multi-file --audio_files run to OOM partway through, even though each file fits comfortably on its own (microsoft#368). Explicitly drop the per-batch tensors and clear the CUDA cache after each batch so freed memory is returned to the allocator's free pool before the next file is processed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018vBGcq8YxMgbF58qx7C4cP
Author
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.
Summary
demo/vibevoice_asr_inference_from_file.pyOOMs partway through a multi-file--audio_filesrun even though every file fits comfortably on its own.transcribe_batch()keptinputs(including the generated KV cache) andoutput_idsreferenced until the next loop iteration overwrote them, letting PyTorch's CUDA caching allocator accumulate cached-but-idle, fragmented memory across files.torch.cuda.empty_cache()/gc.collect()so freed memory is returned to the allocator's free pool before the next file is processed.Test plan
python3 -m py_compile demo/vibevoice_asr_inference_from_file.py--audio_fileson a 24GB GPU) to confirm the run no longer OOMs on the 3rd/4th file — I don't have a comparable GPU set up locally, so this needs verification from someone who can reproduce the original issue.🤖 Generated with Claude Code
https://claude.ai/code/session_018vBGcq8YxMgbF58qx7C4cP