Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/gpu decode #44

Merged
merged 3 commits into from
Dec 20, 2024
Merged

Feat/gpu decode #44

merged 3 commits into from
Dec 20, 2024

Conversation

LemurPwned
Copy link
Owner

@LemurPwned LemurPwned commented Dec 20, 2024

Summary by Sourcery

Add experimental GPU decoding support for NVIDIA GPUs. Update documentation to describe the new feature and its limitations.

New Features:

  • Add experimental support for GPU-based video decoding using NVIDIA GPUs.

Tests:

  • Add tests for the new GPU video sampler.

Copy link
Contributor

sourcery-ai bot commented Dec 20, 2024

Reviewer's Guide by Sourcery

This pull request introduces GPU decoding support as an experimental feature. It adds a --use-gpu-decoder flag to the command-line interface and a corresponding configuration option. The implementation uses the PyNvVideoCodec library for decoding and includes considerations for timestamp estimation and keyframe handling. Documentation and dependencies are updated accordingly.

Sequence diagram for GPU video decoding process

sequenceDiagram
    participant User
    participant GPUVideoSampler
    participant CUDA
    participant NvDecoder
    User->>GPUVideoSampler: sample(video_path)
    GPUVideoSampler->>CUDA: init()
    GPUVideoSampler->>CUDA: create context
    GPUVideoSampler->>NvDecoder: create decoder
    loop For each packet
        NvDecoder->>NvDecoder: decode frame
        NvDecoder->>GPUVideoSampler: return decoded frame
        GPUVideoSampler->>GPUVideoSampler: process frame
    end
    GPUVideoSampler->>CUDA: cleanup context
Loading

Class diagram showing the new GPU sampler implementation

classDiagram
    class BaseSampler {
        +sample(video_path: str)
        +write_queue(path: str, q: Queue, subs: str)
        +init_sampler()
    }
    class VideoSampler {
        +sample(video_path: str, subs: str)
        +write_queue(video_path: str, q: Queue, subs: str)
    }
    class GPUVideoSampler {
        +sample(video_path: str, subs: str)
        note for GPUVideoSampler "New GPU-based implementation"
    }
    BaseSampler <|-- VideoSampler
    VideoSampler <|-- GPUVideoSampler
Loading

File-Level Changes

Change Details Files
Added GPU decoding support.
  • Added --use-gpu-decoder flag to enable GPU decoding.
  • Added use_gpu_decoder option to the SamplerConfig.
  • Added GPUVideoSampler class.
  • Updated documentation to describe GPU decoding usage and limitations.
  • Added PyNvVideoCodec to dependencies.
  • Updated changelog to reflect the addition of GPU decoding support.
  • Added a config file example for GPU decoding.
  • Refactored type hints for optional arguments.
  • Added error handling for missing GPU decoding dependencies.
video_sampler/__main__.py
video_sampler/config.py
video_sampler/samplers/__init__.py
video_sampler/samplers/gpu_sampler.py
video_sampler/samplers/video_sampler.py
video_sampler/samplers/base_sampler.py
pyproject.toml
README.md
CHANGELOG.md
configs/hash_gpu.yaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@LemurPwned LemurPwned linked an issue Dec 20, 2024 that may be closed by this pull request
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @LemurPwned - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 4 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

video_sampler/samplers/gpu_sampler.py Outdated Show resolved Hide resolved
video_sampler/samplers/gpu_sampler.py Outdated Show resolved Hide resolved
video_sampler/samplers/gpu_sampler.py Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@LemurPwned LemurPwned merged commit 019e7a9 into main Dec 20, 2024
3 checks passed
@LemurPwned LemurPwned deleted the feat/gpu-decode branch December 20, 2024 13:18
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.

Add GPU decoding for faster sampling
1 participant