Fix CUDA context leak during NVENC probing - #424
Merged
Conversation
Contributor
Greptile SummaryRestores the initialized PyTorch CUDA device after every hardware-encoder probe outcome, preventing PyNvVideoCodec probing from contaminating subsequent model execution.
Confidence Score: 5/5The PR appears safe to merge, with CUDA-device restoration consistently applied across all hardware-probe outcomes. The new wrapper preserves existing encoder-selection behavior while ensuring its cleanup runs through a Important Files Changed
Reviews (1): Last reviewed commit: "Fix CUDA context leak during NVENC probi..." | Re-trigger Greptile |
Collaborator
Author
|
/ok to test d4f3532 |
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
Restore PyTorch's CUDA device context after probing PyNvVideoCodec for NVENC support.
GetEncoderCapscan replace the calling thread's active CUDA context when the probe fails. Lingbot then falls back to aiortc, but subsequent Triton kernels run with the wrong context and fail withinvalid resource handle. Retrying the partially advanced rollout produces the secondaryAR step out of ordererror.The encoder-selection boundary now restores the original PyTorch device context in a
finallyblock for every hardware-probe outcome.