Skip to content

Commit

Permalink
Help specify the version of the package on pip list and pip commands
Browse files Browse the repository at this point in the history
  • Loading branch information
hmaarrfk committed Dec 15, 2024
1 parent 924da6a commit 980621c
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 73 deletions.
8 changes: 0 additions & 8 deletions .ci_support/migrations/pytorch113.yaml

This file was deleted.

67 changes: 3 additions & 64 deletions recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,88 +8,27 @@ c_stdlib_version: # [osx and x86_64]
# Needs higher stdlib for CUDNN9
# CUDA 12 on aarch needs newer glibc, which requires us to override
# the whole monster zip just to bump c_stdlib_version / docker_image
# We have dropped 11.8 due to lack of interest from conda-forge pytorch maintainers
c_stdlib_version: # [linux and aarch64]
- 2.17 # [linux and aarch64]
- 2.17 # [linux and aarch64]
- 2.28 # [linux and aarch64]
- 2.28 # [linux and aarch64]
docker_image: # [linux and aarch64]
- quay.io/condaforge/linux-anvil-cos7-x86_64 # [linux and aarch64]
- quay.io/condaforge/linux-anvil-cuda:11.8 # [linux and aarch64]
- quay.io/condaforge/linux-anvil-alma-x86_64:8 # [linux and aarch64]
- quay.io/condaforge/linux-anvil-alma-x86_64:8 # [linux and aarch64]
- quay.io/condaforge/linux-anvil-x86_64:cos7 # [linux and aarch64]
- quay.io/condaforge/linux-anvil-x86_64:alma9 # [linux and aarch64]
# rest just to make smithy happy
c_compiler_version: # [linux and aarch64]
- 13 # [linux and aarch64]
- 11 # [linux and aarch64]
- 12 # [linux and aarch64]
- 12 # [linux and aarch64]
cxx_compiler_version: # [linux and aarch64]
- 13 # [linux and aarch64]
- 11 # [linux and aarch64]
- 12 # [linux and aarch64]
- 12 # [linux and aarch64]
fortran_compiler_version: # [linux and aarch64]
- 13 # [linux and aarch64]
- 11 # [linux and aarch64]
- 12 # [linux and aarch64]
- 12 # [linux and aarch64]
cdt_name: # [linux and aarch64]
- cos7 # [linux and aarch64]
- cos7 # [linux and aarch64]
- cos7 # [linux and aarch64]
- cos7 # [linux and aarch64]
cuda_compiler: # [linux and aarch64]
- None # [linux and aarch64]
- nvcc # [linux and aarch64]
- cuda-nvcc # [linux and aarch64]
- cuda-nvcc # [linux and aarch64]
cuda_compiler_version: # [linux and aarch64]
- None # [linux and aarch64]
- 11.8 # [linux and aarch64]
- 12.0 # [linux and aarch64]
- 12.6 # [linux and aarch64]
# end override of monster zip

c_stdlib_version: # [linux64]
- 2.17 # [linux64]
- 2.17 # [linux64]
- 2.17 # [linux64]
- 2.28 # [linux64]
docker_image: # [linux64]
- quay.io/condaforge/linux-anvil-cos7-x86_64 # [linux64]
- quay.io/condaforge/linux-anvil-cuda:11.8 # [linux64]
- quay.io/condaforge/linux-anvil-cos7-x86_64 # [linux64]
- quay.io/condaforge/linux-anvil-alma-x86_64:8 # [linux64]
# rest just to make smithy happy
c_compiler_version: # [linux64]
- 13 # [linux64]
- 11 # [linux64]
- 12 # [linux64]
- 12 # [linux64]
cxx_compiler_version: # [linux64]
- 13 # [linux64]
- 11 # [linux64]
- 12 # [linux64]
- 12 # [linux64]
fortran_compiler_version: # [linux64]
- 13 # [linux64]
- 11 # [linux64]
- 12 # [linux64]
- 12 # [linux64]
cdt_name: # [linux64]
- cos7 # [linux64]
- cos7 # [linux64]
- cos7 # [linux64]
- cos7 # [linux64]
cuda_compiler: # [linux64]
- None # [linux64]
- nvcc # [linux64]
- cuda-nvcc # [linux64]
- cuda-nvcc # [linux64]
cuda_compiler_version: # [linux64]
- None # [linux64]
- 11.8 # [linux64]
- 12.0 # [linux64]
- 12.6 # [linux64]

16 changes: 15 additions & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@ source:
# known flaky test https://github.com/pytorch/vision/blob/9e78fe29e0851b10eb8fba0b88cc521ad67cf322/test/test_image.py#L840
- patches/0003-Skip-OSS-CI-in-conda-forge-as-well.patch

# Can likely remove after 0.20.1
# https://github.com/pytorch/vision/pull/8776
- patches/8776_compatibility_with_pyav_14.patch

build:
string: cpu_py{{ CONDA_PY }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} # [cuda_compiler_version == "None"]
string: cuda{{ cuda_compiler_version | replace('.', '') }}py{{ CONDA_PY }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} # [cuda_compiler_version != "None"]
number: 0
number: 1
script_env:
# required by the setup.py script to find the right version in 0.20.1
- BUILD_VERSION={{ version }}
skip: true # [win]
# aarch doesn't have a build for cuda 11.8 yet
skip: true # [ aarch64 and cuda_compiler_version == "11.8"]
Expand Down Expand Up @@ -70,6 +77,7 @@ requirements:
{% endif %}
- libjpeg-turbo
- libpng
- libwebp
# https://github.com/pytorch/vision/pull/8406/files#r1730151047
- giflib
# Specify lgpl version of ffmpeg so that there are
Expand Down Expand Up @@ -101,6 +109,7 @@ test:
- expecttest
- scipy
- pytest-mock
- pip
source_files:
- test
- references
Expand Down Expand Up @@ -172,6 +181,11 @@ test:
# 2024/02 These tests assert warnings and in PyTorch 2.1.2 the number of warnings increased
# causing them to fail
{% set tests_to_skip = tests_to_skip + " or test_pretrained_pos or test_equivalent_behavior_weights" %}
# use pip list to manually check that the version is correctly reported
# Otherwise downstream package's pip check may fail
- pip list
- pip list | grep torchvision | grep {{ version }} # [unix]
- pip check
- pytest --verbose -k "not ({{ tests_to_skip }})" --durations=50 test/ # [not aarch64]
- pytest -k "not ({{ tests_to_skip }})" --durations=50 test/ # [aarch64 and (build_platform == target_platform)]

Expand Down
93 changes: 93 additions & 0 deletions recipe/patches/8776_compatibility_with_pyav_14.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
From 634b95cf2cdef89f63a1be8712c2853a4ad6a7ce Mon Sep 17 00:00:00 2001
From: Nicolas Hug <[email protected]>
Date: Mon, 2 Dec 2024 13:51:08 +0000
Subject: [PATCH 1/2] Fix pyav 14 error

---
torchvision/io/video.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/torchvision/io/video.py b/torchvision/io/video.py
index 9f768ed555d..d81b846c12f 100644
--- a/torchvision/io/video.py
+++ b/torchvision/io/video.py
@@ -155,7 +155,13 @@ def write_video(

for img in video_array:
frame = av.VideoFrame.from_ndarray(img, format="rgb24")
- frame.pict_type = "NONE"
+ try:
+ frame.pict_type = "NONE"
+ except TypeError:
+ from av.video.frame import PictureType # noqa
+
+ frame.pict_type = PictureType.NONE
+
for packet in stream.encode(frame):
container.mux(packet)


From 0c0cb14e2e180af75b742b890de722a50363c60e Mon Sep 17 00:00:00 2001
From: Nicolas Hug <[email protected]>
Date: Mon, 2 Dec 2024 16:43:58 +0000
Subject: [PATCH 2/2] oenfljanefa

---
torchvision/io/video.py | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/torchvision/io/video.py b/torchvision/io/video.py
index d81b846c12f..2e3dbed65a2 100644
--- a/torchvision/io/video.py
+++ b/torchvision/io/video.py
@@ -26,6 +26,10 @@
install PyAV on your system.
"""
)
+ try:
+ FFmpegError = av.FFmpegError # from av 14 https://github.com/PyAV-Org/PyAV/blob/main/CHANGELOG.rst
+ except AttributeError:
+ FFmpegError = av.AVError
except ImportError:
av = ImportError(
"""\
@@ -221,7 +225,7 @@ def _read_from_stream(
try:
# TODO check if stream needs to always be the video stream here or not
container.seek(seek_offset, any_frame=False, backward=True, stream=stream)
- except av.AVError:
+ except FFmpegError:
# TODO add some warnings in this case
# print("Corrupted file?", container.name)
return []
@@ -234,7 +238,7 @@ def _read_from_stream(
buffer_count += 1
continue
break
- except av.AVError:
+ except FFmpegError:
# TODO add a warning
pass
# ensure that the results are sorted wrt the pts
@@ -356,7 +360,7 @@ def read_video(
)
info["audio_fps"] = container.streams.audio[0].rate

- except av.AVError:
+ except FFmpegError:
# TODO raise a warning?
pass

@@ -447,10 +451,10 @@ def read_video_timestamps(filename: str, pts_unit: str = "pts") -> Tuple[List[in
video_time_base = video_stream.time_base
try:
pts = _decode_video_timestamps(container)
- except av.AVError:
+ except FFmpegError:
warnings.warn(f"Failed decoding frames for file {filename}")
video_fps = float(video_stream.average_rate)
- except av.AVError as e:
+ except FFmpegError as e:
msg = f"Failed to open container for {filename}; Caught error: {e}"
warnings.warn(msg, RuntimeWarning)

0 comments on commit 980621c

Please sign in to comment.