Skip to content

Commit c6bade9

Browse files
author
pytorchbot
committed
2025-10-09 nightly release (986f10c)
1 parent 50a1de8 commit c6bade9

File tree

8 files changed

+40
-15
lines changed

8 files changed

+40
-15
lines changed

.github/workflows/build_ffmpeg.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
fail-fast: false
2929
matrix:
30-
ffmpeg-version: ["4.4.4", "5.1.4", "6.1.1", "7.0.1"]
30+
ffmpeg-version: ["4.4.4", "5.1.4", "6.1.1", "7.0.1", "8.0"]
3131
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
3232
permissions:
3333
id-token: write
@@ -52,7 +52,7 @@ jobs:
5252
strategy:
5353
fail-fast: false
5454
matrix:
55-
ffmpeg-version: ["4.4.4", "5.1.4", "6.1.1", "7.0.1"]
55+
ffmpeg-version: ["4.4.4", "5.1.4", "6.1.1", "7.0.1", "8.0"]
5656
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
5757
with:
5858
job-name: Build
@@ -75,7 +75,7 @@ jobs:
7575
strategy:
7676
fail-fast: false
7777
matrix:
78-
ffmpeg-version: ["4.4.4", "5.1.4", "6.1.1", "7.0.1"]
78+
ffmpeg-version: ["4.4.4", "5.1.4", "6.1.1", "7.0.1", "8.0"]
7979
uses: pytorch/test-infra/.github/workflows/windows_job.yml@main
8080
with:
8181
job-name: Build

packaging/build_ffmpeg.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ if [[ "$(uname)" == Darwin ]]; then
104104
avfilter=libavfilter.10
105105
swscale=libswscale.8
106106
swresample=libswresample.5
107+
elif [[ ${major_ver} == 8 ]]; then
108+
avutil=libavutil.60
109+
avcodec=libavcodec.62
110+
avformat=libavformat.62
111+
avdevice=libavdevice.62
112+
avfilter=libavfilter.11
113+
swscale=libswscale.9
114+
swresample=libswresample.6
107115
else
108116
printf "Error: unexpected FFmpeg major version: %s\n" ${major_ver}
109117
exit 1;

src/torchcodec/_core/BetaCudaDeviceInterface.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,7 @@ BetaCudaDeviceInterface::BetaCudaDeviceInterface(const torch::Device& device)
203203
TORCH_CHECK(
204204
device_.type() == torch::kCUDA, "Unsupported device: ", device_.str());
205205

206-
// Initialize CUDA context with a dummy tensor
207-
torch::Tensor dummyTensorForCudaInitialization = torch::empty(
208-
{1}, torch::TensorOptions().dtype(torch::kUInt8).device(device_));
209-
206+
initializeCudaContextWithPytorch(device_);
210207
nppCtx_ = getNppStreamContext(device_);
211208
}
212209

src/torchcodec/_core/CUDACommon.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ PerGpuCache<NppStreamContext> g_cached_npp_ctxs(
2323

2424
} // namespace
2525

26+
void initializeCudaContextWithPytorch(const torch::Device& device) {
27+
// It is important for pytorch itself to create the cuda context. If ffmpeg
28+
// creates the context it may not be compatible with pytorch.
29+
// This is a dummy tensor to initialize the cuda context.
30+
torch::Tensor dummyTensorForCudaInitialization = torch::zeros(
31+
{1}, torch::TensorOptions().dtype(torch::kUInt8).device(device));
32+
}
33+
2634
/* clang-format off */
2735
// Note: [YUV -> RGB Color Conversion, color space and color range]
2836
//

src/torchcodec/_core/CUDACommon.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ extern "C" {
2222

2323
namespace facebook::torchcodec {
2424

25+
void initializeCudaContextWithPytorch(const torch::Device& device);
26+
2527
// Unique pointer type for NPP stream context
2628
using UniqueNppContext = std::unique_ptr<NppStreamContext>;
2729

src/torchcodec/_core/CudaDeviceInterface.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,10 @@ CudaDeviceInterface::CudaDeviceInterface(const torch::Device& device)
129129
TORCH_CHECK(
130130
device_.type() == torch::kCUDA, "Unsupported device: ", device_.str());
131131

132-
// It is important for pytorch itself to create the cuda context. If ffmpeg
133-
// creates the context it may not be compatible with pytorch.
134-
// This is a dummy tensor to initialize the cuda context.
135-
torch::Tensor dummyTensorForCudaInitialization = torch::empty(
136-
{1}, torch::TensorOptions().dtype(torch::kUInt8).device(device_));
132+
initializeCudaContextWithPytorch(device_);
133+
134+
// TODO rename this, this is a hardware device context, not a CUDA context!
135+
// See https://github.com/meta-pytorch/torchcodec/issues/924
137136
ctx_ = getCudaContext(device_);
138137
nppCtx_ = getNppStreamContext(device_);
139138
}

src/torchcodec/_core/DeviceInterface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ struct DeviceInterfaceKey {
3232

3333
explicit DeviceInterfaceKey(torch::DeviceType type) : deviceType(type) {}
3434

35-
DeviceInterfaceKey(torch::DeviceType type, const std::string_view& var)
36-
: deviceType(type), variant(var) {}
35+
DeviceInterfaceKey(torch::DeviceType type, const std::string_view& variant)
36+
: deviceType(type), variant(variant) {}
3737
};
3838

3939
class DeviceInterface {

test/test_decoders.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ def test_get_frame_at_av1(self, device):
591591
if device == "cuda" and get_ffmpeg_major_version() == 4:
592592
return
593593

594-
if device == "cuda" and in_fbcode():
594+
if "cuda" in device and in_fbcode():
595595
pytest.skip("decoding on CUDA is not supported internally")
596596

597597
decoder = VideoDecoder(AV1_VIDEO.path, device=device)
@@ -1477,6 +1477,9 @@ def test_beta_cuda_interface_get_frame_at(
14771477
if seek_mode == "approximate" and not supports_approximate_mode(asset):
14781478
pytest.skip("asset doesn't work with approximate mode")
14791479

1480+
if in_fbcode() and asset is AV1_VIDEO:
1481+
pytest.skip("AV1 CUDA not supported internally")
1482+
14801483
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
14811484
beta_decoder = VideoDecoder(
14821485
asset.path, device="cuda:0:beta", seek_mode=seek_mode
@@ -1522,6 +1525,8 @@ def test_beta_cuda_interface_get_frames_at(
15221525
):
15231526
if seek_mode == "approximate" and not supports_approximate_mode(asset):
15241527
pytest.skip("asset doesn't work with approximate mode")
1528+
if in_fbcode() and asset is AV1_VIDEO:
1529+
pytest.skip("AV1 CUDA not supported internally")
15251530

15261531
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
15271532
beta_decoder = VideoDecoder(
@@ -1566,6 +1571,8 @@ def test_beta_cuda_interface_get_frames_at(
15661571
def test_beta_cuda_interface_get_frame_played_at(self, asset, seek_mode):
15671572
if seek_mode == "approximate" and not supports_approximate_mode(asset):
15681573
pytest.skip("asset doesn't work with approximate mode")
1574+
if in_fbcode() and asset is AV1_VIDEO:
1575+
pytest.skip("AV1 CUDA not supported internally")
15691576

15701577
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
15711578
beta_decoder = VideoDecoder(
@@ -1607,6 +1614,8 @@ def test_beta_cuda_interface_get_frame_played_at(self, asset, seek_mode):
16071614
def test_beta_cuda_interface_get_frames_played_at(self, asset, seek_mode):
16081615
if seek_mode == "approximate" and not supports_approximate_mode(asset):
16091616
pytest.skip("asset doesn't work with approximate mode")
1617+
if in_fbcode() and asset is AV1_VIDEO:
1618+
pytest.skip("AV1 CUDA not supported internally")
16101619

16111620
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
16121621
beta_decoder = VideoDecoder(
@@ -1649,6 +1658,8 @@ def test_beta_cuda_interface_get_frames_played_at(self, asset, seek_mode):
16491658
def test_beta_cuda_interface_backwards(self, asset, seek_mode):
16501659
if seek_mode == "approximate" and not supports_approximate_mode(asset):
16511660
pytest.skip("asset doesn't work with approximate mode")
1661+
if in_fbcode() and asset is AV1_VIDEO:
1662+
pytest.skip("AV1 CUDA not supported internally")
16521663

16531664
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
16541665
beta_decoder = VideoDecoder(

0 commit comments

Comments
 (0)