Skip to content

feat(cuda): support current CUDA contexts#2339

Merged
WyattBlue merged 1 commit into
PyAV-Org:mainfrom
Yozer:cuda-current-context
Jul 13, 2026
Merged

feat(cuda): support current CUDA contexts#2339
WyattBlue merged 1 commit into
PyAV-Org:mainfrom
Yozer:cuda-current-context

Conversation

@Yozer

@Yozer Yozer commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

PyTorch may initialize the CUDA primary context before PyAV, causing FFmpeg's primary_ctx setup to fail with EOPNOTSUPP. Workaround is obvious but creating a separate context also adds memory and synchronization overhead.

This exposes FFmpeg's current_ctx option through CudaContext and VideoFrame.from_dlpack, allowing callers to reuse the active context. Existing defaults remain unchanged.

@WyattBlue WyattBlue force-pushed the cuda-current-context branch from 61b46e9 to fca1878 Compare July 13, 2026 22:11
@WyattBlue WyattBlue merged commit 44cbe64 into PyAV-Org:main Jul 13, 2026
WyattBlue added a commit that referenced this pull request Jul 13, 2026
Passing an explicit cuda_context no longer requires restating
primary_ctx/current_ctx; the flags are validated only when given.
current_ctx=True without cuda_context now implies primary_ctx=False.
Also document CudaContext and add a changelog entry for #2339.
WyattBlue added a commit that referenced this pull request Jul 13, 2026
Passing an explicit cuda_context no longer requires restating
primary_ctx/current_ctx; the flags are validated only when given.
current_ctx=True without cuda_context now implies primary_ctx=False.
Also document CudaContext and add a changelog entry for #2339.
WyattBlue added a commit that referenced this pull request Jul 13, 2026
Passing an explicit cuda_context no longer requires restating
primary_ctx/current_ctx; the flags are validated only when given.
current_ctx=True without cuda_context now implies primary_ctx=False.
Also document CudaContext and add a changelog entry for #2339.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants