Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Full (dec+filters) ffmpeg-vaapi pipeline for Intel GPU (xpu pytorch backend)#832

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
dvrogozh wants to merge4 commits intometa-pytorch:main
base:main
Choose a base branch
Loading
fromdvrogozh:filters-vaapi

Conversation

@dvrogozh
Copy link
Contributor

@dvrogozhdvrogozh commentedAug 22, 2025
edited
Loading

Background

I submit this PR to illustrate filter graphs usage for multi-gpu support on the example of ffmpeg vaapi backend. The difference of this PR from#558 is usage of ffmpeg filters for color space conversion. Pay attention thatXpuDeviceInterface implemented in the last commit of this PR can further be generalized to support any hw (and cpu) ffmpeg backend by having these 3 backend specific stuff:

  1. Function to create ffmpeg HW device context from the torch device (should returnAVBufferRef)
  2. Settings to select and tune HW backend specific filters (scale vs.scale_vaapi vs.scale_cuda)
  3. Function to covert outputAVFrame (from filters) to the tensor

The reason of this PR being a draft is that currently full (dec+filters) ffmpeg-vaapi pipeline generates worse quality output vs. pipeline in#558. Reason for that is handling of color standards inscale_vaapi filter and Intel media driver. I believe there are some issues here in these components which needs to be reported and fixed. I will follow up.

Details

This commit enables support for Intel GPUs in torchcodec. It adds:

  • ffmpeg-vaapi for decoding and color space conversion from decoding
    output to RGBA
  • RGBA surface import as torch tensor (on torch xpu device)
  • RGBA to RGB24 tensor slicing

To build torchcodec with Intel GPU support:

  • Install pytorch with XPU backend support. For example, with:
pip3 install torch --index-url https://download.pytorch.org/whl/xpu

CC:@scotts@NicolasHug@eromomon

FFmpeg filter graphs allow to cover a lot of use cases includingcpu and gpu usages. This commit moves filter graph support out ofCPU device interface which allows flexibility in usage acrossother contexts.Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@gmail.com>
Dmitry Rogozhkinand others added2 commitsAugust 22, 2025 13:07
Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@gmail.com>
This commit enables support for Intel GPUs in torchcodec. It adds:* ffmpeg-vaapi for decoding and color space conversion from decoding  output to RGBA* RGBA surface import as torch tensor (on torch xpu device)* RGBA to RGB24 tensor slicingTo build torchcodec with Intel GPU support:* Install pytorch with XPU backend support. For example, with:```pip3 install torch --index-urlhttps://download.pytorch.org/whl/xpu```* Install oneAPI development environment followinghttps://github.com/pytorch/pytorch?tab=readme-ov-file#intel-gpu-support* Build and install FFmpeg with `--enable-vaapi`* Install torcheval (for tests): `pip3 install torcheval`* Build torchcodec with: `ENABLE_XPU=1 python3 setup.py devel`Notes:* RGB24 is not supported color format on current Intel GPUs (as it  is considered to be suboptimal due to odd alignments)* Intel media and compute APIs can't seamlessly work with the  memory from each other. For example, Intel computes's Unified  Shared Memory pointers are not recognized by media APIs. Thus,  lower level sharing via dma fds is needed. This alos makes this  part of the solution OS dependent.* Color space conversion algoriths might be quite different as it  happens for Intel. This requires to check PSNR values instead of  per-pixel atol/rtol differences.* Installing oneAPI environment is neded due topytorch/pytorch#149075This commit was primary verfied on Intel Battlemage G21 (0xe20b) andIntel Data Center GPU Flex (0x56c0).Co-authored-by: Edgar Romo Montiel <edgar.romo.montiel@intel.com>Signed-off-by: Edgar Romo Montiel <edgar.romo.montiel@intel.com>Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>Use ffmpeg-vaapi filters for color conversion in XPU interfaceSigned-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@gmail.com>
Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

CLA SignedThis label is managed by the Meta Open Source bot.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@dvrogozh

[8]ページ先頭

©2009-2025 Movatter.jp