Skip to content

Commit cb3bd78

Browse files
committed
Don't build webp support on rocm
1 parent 21ce0e7 commit cb3bd78

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,12 @@ def make_image_extension():
320320
else:
321321
warnings.warn("Building torchvision without JPEG support")
322322

323-
if USE_WEBP:
323+
if USE_WEBP and IS_ROCM:
324+
warnings.warn(
325+
"Cannot enable webp support on rocm. "
326+
"See https://github.com/pytorch/vision/pull/8724#issuecomment-2503964558."
327+
)
328+
elif USE_WEBP:
324329
webp_found, webp_include_dir, webp_library_dir = find_library(header="webp/decode.h")
325330
if webp_found:
326331
print("Building torchvision with WEBP support")

test/test_image.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
IS_MACOS = sys.platform == "darwin"
4646
PILLOW_VERSION = tuple(int(x) for x in PILLOW_VERSION.split("."))
4747
WEBP_TEST_IMAGES_DIR = os.environ.get("WEBP_TEST_IMAGES_DIR", "")
48+
IS_ROCM = torch.version.hip is not None
49+
# See https://github.com/pytorch/vision/pull/8724#issuecomment-2503964558
50+
ROCM_WEBP_MESSAGE = "ROCM not built with webp support."
4851

4952
# Hacky way of figuring out whether we compiled with libavif/libheif (those are
5053
# currenlty disabled by default)
@@ -869,6 +872,7 @@ def test_decode_gif(tmpdir, name, scripted):
869872
(decode_jpeg, "Not a JPEG file"),
870873
(decode_gif, re.escape("DGifOpenFileName() failed - 103")),
871874
(decode_webp, "WebPGetFeatures failed."),
875+
pytest.param(decode_webp, "WebPGetFeatures failed.", marks=pytest.mark.skipif(IS_ROCM, reason=ROCM_WEBP_MESSAGE)),
872876
]
873877
if DECODE_AVIF_ENABLED:
874878
decode_fun_and_match.append((_decode_avif, "BMFF parsing failed"))
@@ -889,6 +893,7 @@ def test_decode_bad_encoded_data(decode_fun, match):
889893
decode_fun(encoded_data)
890894

891895

896+
@pytest.mark.skipif(IS_ROCM, reason=ROCM_WEBP_MESSAGE)
892897
@pytest.mark.parametrize("decode_fun", (decode_webp, decode_image))
893898
@pytest.mark.parametrize("scripted", (False, True))
894899
def test_decode_webp(decode_fun, scripted):
@@ -905,6 +910,7 @@ def test_decode_webp(decode_fun, scripted):
905910
# including within the repo. The test images were downloaded manually from the
906911
# different pages of https://developers.google.com/speed/webp/gallery
907912
@pytest.mark.skipif(not WEBP_TEST_IMAGES_DIR, reason="WEBP_TEST_IMAGES_DIR is not set")
913+
@pytest.mark.skipif(IS_ROCM, reason=ROCM_WEBP_MESSAGE)
908914
@pytest.mark.parametrize("decode_fun", (decode_webp, decode_image))
909915
@pytest.mark.parametrize("scripted", (False, True))
910916
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)