Enable Intel GPU support in torchcodec on Linux (xpu device)#558
Open
dvrogozh wants to merge 1 commit intometa-pytorch:mainfrom
Open
Enable Intel GPU support in torchcodec on Linux (xpu device)#558dvrogozh wants to merge 1 commit intometa-pytorch:mainfrom
dvrogozh wants to merge 1 commit intometa-pytorch:mainfrom
Conversation
Closed
Collaborator
Author
|
Thanks to @eromomon, here is a rebase of the xpu enabling PR. As expected, the core part now just has xpu device interface files added without changes in a common parts of torchcodec. Tests have a number of changes though - we will try to suggest some patches in separate PRs. |
Collaborator
Author
|
Rebased on top of latest changes in main to take in: |
Collaborator
Author
|
Rebased on top of latest changes in main to take in: |
This commit enables support for Intel GPUs in torchcodec. It adds: * ffmpeg-vaapi for decoding * VAAPI based color space conversion (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 ``` * Install oneAPI development environment following https://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 to pytorch/pytorch#149075 This commit was primary verfied on Intel Battlemage G21 (0xe20b) and Intel 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>
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.
Fixes: #559
This commit enables support for Intel GPUs in torchcodec. It adds:
To build torchcodec with Intel GPU support:
--enable-vaapipip3 install torchevalENABLE_XPU=1 python3 setup.py develNotes:
This commit was primary verfied on Intel Battlemage G21 (0xe20b) and Intel 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
CC: @scotts, @NicolasHug, @EikanWang