From c01d2af64374caf56c266705aba36fb81e54023e Mon Sep 17 00:00:00 2001 From: Prabhat Roy Date: Wed, 15 Sep 2021 19:00:23 +0100 Subject: [PATCH 1/2] Skip building torchvision with ffmpeg when python==3.9 --- setup.py | 7 ++++++- test/common_utils.py | 4 +--- test/test_video_reader.py | 10 +--------- test/test_videoapi.py | 2 -- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/setup.py b/setup.py index 09f951b1090..be66c3eb163 100644 --- a/setup.py +++ b/setup.py @@ -351,7 +351,12 @@ def get_extensions(): ffmpeg_exe = distutils.spawn.find_executable('ffmpeg') has_ffmpeg = ffmpeg_exe is not None - if sys.platform != 'linux': + # Building torchvision with ffmpeg on MacOS or with Python 3.9 causes + # crash. See the following GitHub issues for more details. + # https://github.com/pytorch/pytorch/issues/65000 + # https://github.com/pytorch/vision/issues/3367 + if sys.platform != 'linux' or ( + sys.version_info.major == 3 and sys.version_info.minor == 9): has_ffmpeg = False if has_ffmpeg: try: diff --git a/test/common_utils.py b/test/common_utils.py index 1a2e3042365..5aad4a6dd24 100644 --- a/test/common_utils.py +++ b/test/common_utils.py @@ -20,9 +20,7 @@ import numpy as np from PIL import Image -IS_PY39 = sys.version_info.major == 3 and sys.version_info.minor == 9 -PY39_SEGFAULT_SKIP_MSG = "Segmentation fault with Python 3.9, see https://github.com/pytorch/vision/issues/3367" -PY39_SKIP = pytest.mark.skipif(IS_PY39, reason=PY39_SEGFAULT_SKIP_MSG) + IN_CIRCLE_CI = os.getenv("CIRCLECI", False) == 'true' IN_RE_WORKER = os.environ.get("INSIDE_RE_WORKER") is not None IN_FBCODE = os.environ.get("IN_FBCODE_TORCHVISION") == "1" diff --git a/test/test_video_reader.py b/test/test_video_reader.py index 66e92d88dba..41ca3e9b08a 100644 --- a/test/test_video_reader.py +++ b/test/test_video_reader.py @@ -12,7 +12,7 @@ from numpy.random import randint from torchvision import set_video_backend from torchvision.io import _HAS_VIDEO_OPT -from common_utils import PY39_SKIP, assert_equal +from common_utils import assert_equal try: @@ -423,7 +423,6 @@ def test_stress_test_read_video_from_file(self): audio_timebase_den, ) - @PY39_SKIP def test_read_video_from_file(self): """ Test the case when decoder starts with a video file to decode frames. @@ -469,7 +468,6 @@ def test_read_video_from_file(self): # compare decoding results self.compare_decoding_result(tv_result, pyav_result, config) - @PY39_SKIP def test_read_video_from_file_read_single_stream_only(self): """ Test the case when decoder starts with a video file to decode frames, and @@ -770,7 +768,6 @@ def test_read_video_from_file_rescale_width_and_height(self): assert tv_result[0].size(1) == height assert tv_result[0].size(2) == width - @PY39_SKIP def test_read_video_from_file_audio_resampling(self): """ Test the case when decoder starts with a video file to decode frames, and @@ -826,7 +823,6 @@ def test_read_video_from_file_audio_resampling(self): ) assert aframes.size(0) == approx(int(duration * asample_rate.item()), abs=0.1 * asample_rate.item()) - @PY39_SKIP def test_compare_read_video_from_memory_and_file(self): """ Test the case when video is already in memory, and decoder reads data in memory @@ -893,7 +889,6 @@ def test_compare_read_video_from_memory_and_file(self): # finally, compare results decoded from memory and file self.compare_decoding_result(tv_result_memory, tv_result_file) - @PY39_SKIP def test_read_video_from_memory(self): """ Test the case when video is already in memory, and decoder reads data in memory @@ -938,7 +933,6 @@ def test_read_video_from_memory(self): self.check_separate_decoding_result(tv_result, config) self.compare_decoding_result(tv_result, pyav_result, config) - @PY39_SKIP def test_read_video_from_memory_get_pts_only(self): """ Test the case when video is already in memory, and decoder reads data in memory. @@ -1008,7 +1002,6 @@ def test_read_video_from_memory_get_pts_only(self): assert not tv_result_pts_only[5].numel() self.compare_decoding_result(tv_result, tv_result_pts_only) - @PY39_SKIP def test_read_video_in_range_from_memory(self): """ Test the case when video is already in memory, and decoder reads data in memory. @@ -1184,7 +1177,6 @@ def test_probe_video_from_memory_script(self): probe_result = scripted_fun(video_tensor) self.check_meta_result(probe_result, config) - @PY39_SKIP def test_read_video_from_memory_scripted(self): """ Test the case when video is already in memory, and decoder reads data in memory diff --git a/test/test_videoapi.py b/test/test_videoapi.py index 734620e8f74..1bcce29670d 100644 --- a/test/test_videoapi.py +++ b/test/test_videoapi.py @@ -9,7 +9,6 @@ from torchvision.io import _HAS_VIDEO_OPT, VideoReader from torchvision.datasets.utils import download_url -from common_utils import PY39_SKIP try: import av @@ -65,7 +64,6 @@ def fate(name, path="."): @pytest.mark.skipif(_HAS_VIDEO_OPT is False, reason="Didn't compile with ffmpeg") -@PY39_SKIP class TestVideoApi: @pytest.mark.skipif(av is None, reason="PyAV unavailable") def test_frame_reading(self): From 6417d77946e12ce2be3d9fc7831b49fafe0a5d11 Mon Sep 17 00:00:00 2001 From: Prabhat Roy Date: Thu, 16 Sep 2021 10:13:51 +0100 Subject: [PATCH 2/2] Add FIXME to comments --- setup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index be66c3eb163..6bdd14684b4 100644 --- a/setup.py +++ b/setup.py @@ -351,10 +351,10 @@ def get_extensions(): ffmpeg_exe = distutils.spawn.find_executable('ffmpeg') has_ffmpeg = ffmpeg_exe is not None - # Building torchvision with ffmpeg on MacOS or with Python 3.9 causes - # crash. See the following GitHub issues for more details. - # https://github.com/pytorch/pytorch/issues/65000 - # https://github.com/pytorch/vision/issues/3367 + # FIXME: Building torchvision with ffmpeg on MacOS or with Python 3.9 + # FIXME: causes crash. See the following GitHub issues for more details. + # FIXME: https://github.com/pytorch/pytorch/issues/65000 + # FIXME: https://github.com/pytorch/vision/issues/3367 if sys.platform != 'linux' or ( sys.version_info.major == 3 and sys.version_info.minor == 9): has_ffmpeg = False