Fix GPU memory accumulation across files in ASR batch inference demo - #439
Open
Ammar Hashmi (ammar-iitm) wants to merge 1 commit into
Open
Ammar Hashmi (ammar-iitm) wants to merge 1 commit into
Ammar Hashmi (ammar-iitm) wants to merge 1 commit into
Conversation
transcribe_batch() never released the CUDA caching allocator's freed blocks between files. Since audio files vary in length, each batch produces differently-shaped tensors, so freed blocks from one file's batch often can't be reused for the next file's shapes. This fragmentation compounds across a multi-file --audio_files run and can OOM partway through even though each file fits fine on its own (reported in microsoft#368). Add a _release_memory() step (gc.collect + empty_cache for cuda/xpu/mps) run after each batch in transcribe_batch(). Fixes microsoft#368 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016fM2LafALmBK16KnFWjsp7
Author
|
@microsoft-github-policy-service agree [company="default"] |
Author
|
@microsoft-github-policy-service agree |
2 tasks
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 each file fits comfortably on its own.transcribe_batch()never released the CUDA caching allocator's freed blocks between files/batches. Since audio files vary in length, each batch produces differently-shaped tensors, so freed memory blocks from one file's batch often aren't reusable for the next file's shapes — fragmentation compounds across the run._release_memory()step (gc.collect()+empty_cache()for cuda/xpu/mps) run at the end of eachtranscribe_batch()call, so allocator state is reset between files/batches.Test plan
python3 -m py_compile demo/vibevoice_asr_inference_from_file.py🤖 Generated with Claude Code
https://claude.ai/code/session_016fM2LafALmBK16KnFWjsp7