From adcb1135c27e71a21cceed9591bf514f6375738f Mon Sep 17 00:00:00 2001 From: guptaishaan Date: Sun, 2 Aug 2026 15:56:38 -0700 Subject: [PATCH] Remove the orphaned onnxruntime Dockerfiles #11803 dropped onnx and flax from the docker build matrix in build_docker_images.yml. #12151 finished the flax half by deleting docker/diffusers-flax-*, but the two onnxruntime directories were left behind, so docker/ has listed two images for thirteen months that neither job in the workflow builds. Their :latest tags on Docker Hub have been frozen since 2025-06-27 as a result. Delete docker/diffusers-onnxruntime-cpu and docker/diffusers-onnxruntime-cuda, mirroring what was done for flax. Nothing else in the repo references them: every test workflow filters ONNX out with -k "not Onnx", run_nightly_onnx_tests is commented out, and no doc or script names the images. Add tests/others/test_docker_images.py, which asserts that the directories under docker/ are exactly the images named in both jobs of build_docker_images.yml, the PR-time ALLOWED_IMAGES array and the nightly strategy.matrix.image-name list. It fails on both before this change and passes after. This does not remove the stale tags from Docker Hub, which needs registry credentials. Fixes #14325 --- docker/diffusers-onnxruntime-cpu/Dockerfile | 49 -------------------- docker/diffusers-onnxruntime-cuda/Dockerfile | 49 -------------------- tests/others/test_docker_images.py | 26 +++++++++++ 3 files changed, 26 insertions(+), 98 deletions(-) delete mode 100644 docker/diffusers-onnxruntime-cpu/Dockerfile delete mode 100644 docker/diffusers-onnxruntime-cuda/Dockerfile create mode 100644 tests/others/test_docker_images.py diff --git a/docker/diffusers-onnxruntime-cpu/Dockerfile b/docker/diffusers-onnxruntime-cpu/Dockerfile deleted file mode 100644 index 25bbb347cf0b..000000000000 --- a/docker/diffusers-onnxruntime-cpu/Dockerfile +++ /dev/null @@ -1,49 +0,0 @@ -FROM ubuntu:20.04 -LABEL maintainer="Hugging Face" -LABEL repository="diffusers" - -ENV DEBIAN_FRONTEND=noninteractive - -RUN apt-get -y update \ - && apt-get install -y software-properties-common \ - && add-apt-repository ppa:deadsnakes/ppa - -RUN apt install -y bash \ - build-essential \ - git \ - git-lfs \ - curl \ - ca-certificates \ - libsndfile1-dev \ - libgl1 \ - python3.10 \ - python3-pip \ - python3.10-venv && \ - rm -rf /var/lib/apt/lists - -# make sure to use venv -RUN python3.10 -m venv /opt/venv -ENV PATH="/opt/venv/bin:$PATH" - -# pre-install the heavy dependencies (these can later be overridden by the deps from setup.py) -RUN python3 -m pip install --no-cache-dir --upgrade pip uv==0.1.11 && \ - python3 -m uv pip install --no-cache-dir \ - torch==2.10.0 \ - torchvision==0.25.0 \ - torchaudio==2.10.0 \ - onnxruntime \ - --extra-index-url https://download.pytorch.org/whl/cpu && \ - python3 -m uv pip install --no-cache-dir \ - accelerate \ - datasets \ - hf-doc-builder \ - huggingface-hub \ - Jinja2 \ - librosa \ - numpy==1.26.4 \ - scipy \ - tensorboard \ - transformers \ - hf_xet - -CMD ["/bin/bash"] \ No newline at end of file diff --git a/docker/diffusers-onnxruntime-cuda/Dockerfile b/docker/diffusers-onnxruntime-cuda/Dockerfile deleted file mode 100644 index fd425d82c371..000000000000 --- a/docker/diffusers-onnxruntime-cuda/Dockerfile +++ /dev/null @@ -1,49 +0,0 @@ -FROM nvidia/cuda:12.1.0-runtime-ubuntu20.04 -LABEL maintainer="Hugging Face" -LABEL repository="diffusers" - -ENV DEBIAN_FRONTEND=noninteractive - -RUN apt-get -y update \ - && apt-get install -y software-properties-common \ - && add-apt-repository ppa:deadsnakes/ppa - -RUN apt install -y bash \ - build-essential \ - git \ - git-lfs \ - curl \ - ca-certificates \ - libsndfile1-dev \ - libgl1 \ - python3.10 \ - python3-pip \ - python3.10-venv && \ - rm -rf /var/lib/apt/lists - -# make sure to use venv -RUN python3.10 -m venv /opt/venv -ENV PATH="/opt/venv/bin:$PATH" - -# pre-install the heavy dependencies (these can later be overridden by the deps from setup.py) -RUN python3.10 -m pip install --no-cache-dir --upgrade pip uv==0.1.11 && \ - python3.10 -m uv pip install --no-cache-dir \ - torch \ - torchvision \ - torchaudio \ - "onnxruntime-gpu>=1.13.1" \ - --extra-index-url https://download.pytorch.org/whl/cu117 && \ - python3.10 -m uv pip install --no-cache-dir \ - accelerate \ - datasets \ - hf-doc-builder \ - huggingface-hub \ - hf_xet \ - Jinja2 \ - librosa \ - numpy==1.26.4 \ - scipy \ - tensorboard \ - transformers - -CMD ["/bin/bash"] \ No newline at end of file diff --git a/tests/others/test_docker_images.py b/tests/others/test_docker_images.py new file mode 100644 index 000000000000..4f833ad7aff8 --- /dev/null +++ b/tests/others/test_docker_images.py @@ -0,0 +1,26 @@ +import os +import re +import unittest + +import yaml + + +git_repo_path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) +docker_path = os.path.join(git_repo_path, "docker") +workflow_path = os.path.join(git_repo_path, ".github", "workflows", "build_docker_images.yml") + + +class TestDockerImages(unittest.TestCase): + def setUp(self): + self.image_dirs = set(os.listdir(docker_path)) + with open(workflow_path, "r") as f: + self.workflow = yaml.safe_load(f) + + def test_images_are_built_on_pull_requests(self): + run = self.workflow["jobs"]["test-build-docker-images"]["steps"][-1]["run"] + allowed_images = re.search(r"ALLOWED_IMAGES=\(\n(.*?)\)", run, flags=re.DOTALL).group(1) + self.assertSetEqual(set(allowed_images.split()), self.image_dirs) + + def test_images_are_pushed_on_schedule(self): + matrix = self.workflow["jobs"]["build-and-push-docker-images"]["strategy"]["matrix"] + self.assertSetEqual(set(matrix["image-name"]), self.image_dirs)