Skip to content

Commit 0233545

Browse files
author
pytorchbot
committed
2025-12-10 nightly release (2c2a138)
1 parent 904b99a commit 0233545

File tree

5 files changed

+111
-5
lines changed

5 files changed

+111
-5
lines changed

.github/workflows/linux_cuda_aarch64_wheel.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,80 @@ jobs:
5656
architecture: aarch64
5757
build-platform: "python-build-package"
5858
build-command: "BUILD_AGAINST_ALL_FFMPEG_FROM_S3=1 ENABLE_CUDA=1 python -m build --wheel -vvv --no-isolation"
59+
60+
install-and-test:
61+
runs-on: linux.arm64.2xlarge
62+
container:
63+
image: pytorch/manylinuxaarch64-builder:cuda12.6
64+
env:
65+
cuda_version_without_periods: "126"
66+
strategy:
67+
fail-fast: false
68+
matrix:
69+
python-version: ['3.10']
70+
ffmpeg-version-for-tests: ['4.4.2', '5.1.2', '6.1.1', '7.0.1', '8.0']
71+
needs: build
72+
steps:
73+
- uses: actions/download-artifact@v4
74+
with:
75+
name: meta-pytorch_torchcodec__${{ matrix.python-version }}_cu${{ env.cuda_version_without_periods }}_aarch64
76+
path: pytorch/torchcodec/dist/
77+
- name: Setup conda env
78+
uses: conda-incubator/setup-miniconda@v3
79+
with:
80+
auto-update-conda: true
81+
# Using miniforge instead of miniconda ensures that the default
82+
# conda channel is conda-forge instead of main/default. This ensures
83+
# ABI consistency between dependencies:
84+
# https://conda-forge.org/docs/user/transitioning_from_defaults/
85+
miniforge-version: latest
86+
activate-environment: test
87+
python-version: ${{ matrix.python-version }}
88+
- name: Update pip
89+
run: python -m pip install --upgrade pip
90+
- name: Install PyTorch
91+
run: |
92+
${CONDA_RUN} python -m pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cu${{ env.cuda_version_without_periods }}
93+
- name: Install torchcodec from the wheel
94+
run: |
95+
wheel_path=`find pytorch/torchcodec/dist -type f -name "*.whl"`
96+
echo Installing $wheel_path
97+
python -m pip install $wheel_path -vvv
98+
99+
- name: Check out repo
100+
uses: actions/checkout@v3
101+
- name: Install ffmpeg, post build
102+
run: |
103+
# Ideally we would have checked for that before installing the wheel,
104+
# but we need to checkout the repo to access this file, and we don't
105+
# want to checkout the repo before installing the wheel to avoid any
106+
# side-effect. It's OK.
107+
source packaging/helpers.sh
108+
assert_ffmpeg_not_installed
109+
110+
conda install "ffmpeg=${{ matrix.ffmpeg-version-for-tests }}" -c conda-forge
111+
ffmpeg -version
112+
echo LD_LIBRARY_PATH=$CONDA_PREFIX/lib:/usr/local/cuda/lib64/:${LD_LIBRARY_PATH} >> $GITHUB_ENV
113+
114+
- name: Install test dependencies
115+
run: |
116+
# Ideally we would find a way to get those dependencies from pyproject.toml
117+
python -m pip install numpy pytest pillow
118+
119+
- name: Delete the src/ folder just for fun
120+
run: |
121+
# The only reason we checked-out the repo is to get access to the
122+
# tests. We don't care about the rest. Out of precaution, we delete
123+
# the src/ folder to be extra sure that we're running the code from
124+
# the installed wheel rather than from the source.
125+
# This is just to be extra cautious and very overkill because a)
126+
# there's no way the `torchcodec` package from src/ can be found from
127+
# the PythonPath: the main point of `src/` is precisely to protect
128+
# against that and b) if we ever were to execute code from
129+
# `src/torchcodec`, it would fail loudly because the built .so files
130+
# aren't present there.
131+
rm -r src/
132+
ls
133+
- name: Run Python tests
134+
run: |
135+
pytest --override-ini="addopts=-v" test

src/torchcodec/_core/ops.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77

88
import io
99
import json
10+
import os
11+
import shutil
12+
import sys
1013
import warnings
14+
from contextlib import nullcontext
15+
from pathlib import Path
1116
from types import ModuleType
1217

1318
import torch
@@ -22,7 +27,7 @@
2227
_pybind_ops: ModuleType | None = None
2328

2429

25-
def load_torchcodec_shared_libraries():
30+
def load_torchcodec_shared_libraries() -> tuple[int, str]:
2631
# Successively try to load the shared libraries for each version of FFmpeg
2732
# that we support. We always start with the highest version, working our way
2833
# down to the lowest version. Once we can load ALL shared libraries for a
@@ -70,7 +75,8 @@ def load_torchcodec_shared_libraries():
7075
raise RuntimeError(
7176
f"""Could not load libtorchcodec. Likely causes:
7277
1. FFmpeg is not properly installed in your environment. We support
73-
versions 4, 5, 6, 7, and 8.
78+
versions 4, 5, 6, 7, and 8. On Windows, ensure you've installed
79+
the "full-shared" version which ships DLLs.
7480
2. The PyTorch version ({torch.__version__}) is not compatible with
7581
this version of TorchCodec. Refer to the version compatibility
7682
table:
@@ -82,7 +88,21 @@ def load_torchcodec_shared_libraries():
8288
)
8389

8490

85-
ffmpeg_major_version, core_library_path = load_torchcodec_shared_libraries()
91+
if sys.platform == "win32" and hasattr(os, "add_dll_directory"):
92+
# On windows we try to locate the FFmpeg DLLs and temporarily add them to
93+
# the DLL search path. This seems to be needed on some users machine, but
94+
# not on our CI. We don't know why.
95+
if ffmpeg_path := shutil.which("ffmpeg"):
96+
97+
def cm(): # noqa: F811
98+
ffmpeg_dir = Path(ffmpeg_path).parent
99+
return os.add_dll_directory(str(ffmpeg_dir)) # that's the actual CM
100+
101+
else:
102+
cm = nullcontext
103+
104+
with cm():
105+
ffmpeg_major_version, core_library_path = load_torchcodec_shared_libraries()
86106

87107

88108
# Note: We use disallow_in_graph because PyTorch does constant propagation of

test/test_decoders.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,8 @@ def test_get_key_frame_indices(self, device):
11461146
key_frame_indices, h265_reference_key_frame_indices, atol=0, rtol=0
11471147
)
11481148

1149+
# TODO investigate why this is failing from the nightlies of Dec 09 2025.
1150+
@pytest.mark.skip(reason="TODO investigate")
11491151
# TODO investigate why this fails internally.
11501152
@pytest.mark.skipif(in_fbcode(), reason="Compile test fails internally.")
11511153
@pytest.mark.skipif(

test/test_encoders.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import io
22
import json
33
import os
4+
import platform
45
import re
56
import subprocess
67
import sys
@@ -328,7 +329,11 @@ def test_against_cli(
328329

329330
assert_close = torch.testing.assert_close
330331
if sample_rate != asset.sample_rate:
331-
rtol, atol = 0, 1e-3
332+
if platform.machine().lower() == "aarch64":
333+
rtol, atol = 0, 1e-2
334+
else:
335+
rtol, atol = 0, 1e-3
336+
332337
if sys.platform == "darwin":
333338
assert_close = partial(assert_tensor_close_on_at_least, percentage=99)
334339
elif format == "wav":

test/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import os
44
import pathlib
5+
import platform
56
import subprocess
67
import sys
78

@@ -138,7 +139,7 @@ def psnr(a, b, max_val=255) -> float:
138139
# not guarantee bit-for-bit equality across systems and architectures, so we
139140
# also cannot. We currently use Linux on x86_64 as our reference system.
140141
def assert_frames_equal(*args, **kwargs):
141-
if sys.platform == "linux":
142+
if sys.platform == "linux" and "x86" in platform.machine().lower():
142143
if args[0].device.type == "cuda":
143144
atol = 3 if cuda_version_used_for_building_torch() >= (13, 0) else 2
144145
if get_ffmpeg_major_version() == 4:
@@ -150,6 +151,7 @@ def assert_frames_equal(*args, **kwargs):
150151
else:
151152
torch.testing.assert_close(*args, **kwargs, atol=0, rtol=0)
152153
else:
154+
# Here: Windows, MacOS, and Linux for non-x86 architectures like aarch64
153155
torch.testing.assert_close(*args, **kwargs, atol=3, rtol=0)
154156

155157

0 commit comments

Comments
 (0)