Skip to content

Commit bc1d03b

Browse files
Sai-Suraj-27ydshieh
authored andcommitted
Updated docker files to use uv for installing packages (huggingface#36957)
* Updated docker files to use uv pip install as uv is blazingly fast. * Removed -y flag for uv pip uninstall. * Passed --no-build-isolation flag --------- Co-authored-by: Yih-Dar <2521628+ydshieh@users.noreply.github.com>
1 parent 52745d2 commit bc1d03b

14 files changed

+33
-33
lines changed

docker/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
In this folder you will find various docker files, and some subfolders.
44
- dockerfiles (ex: `consistency.dockerfile`) present under `~/docker` are used for our "fast" CIs. You should be able to use them for tasks that only need CPU. For example `torch-light` is a very light weights container (703MiB).
5-
- subfloder contain dockerfiles used for our `slow` CIs, which *can* be used for GPU tasks, but they are **BIG** as they were not specifically designed for a single model / single task. Thus the `~/docker/transformers-pytorch-gpu` includes additional dependencies to allow us to run ALL model tests (say `librosa` or `tesseract`, which you do not need to run LLMs)
5+
- subfolders contain dockerfiles used for our `slow` CIs, which *can* be used for GPU tasks, but they are **BIG** as they were not specifically designed for a single model / single task. Thus the `~/docker/transformers-pytorch-gpu` includes additional dependencies to allow us to run ALL model tests (say `librosa` or `tesseract`, which you do not need to run LLMs)
66

77
Note that in both case, you need to run `uv pip install -e .`, which should take around 5 seconds. We do it outside the dockerfile for the need of our CI: we checkout a new branch each time, and the `transformers` code is thus updated.
88

9-
We are open to contribution, and invite the community to create dockerfiles with potential arguments that properly choose extras depending on the model's dependencies! :hugs:
9+
We are open to contribution, and invite the community to create dockerfiles with potential arguments that properly choose extras depending on the model's dependencies! :hugs:

docker/consistency.dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ ARG REF=main
55
RUN apt-get update && apt-get install -y time git g++ pkg-config make git-lfs
66
ENV UV_PYTHON=/usr/local/bin/python
77
RUN pip install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools GitPython
8-
RUN pip install --no-cache-dir --upgrade 'torch' 'torchaudio' 'torchvision' --index-url https://download.pytorch.org/whl/cpu
8+
RUN uv pip install --no-cache-dir --upgrade 'torch' 'torchaudio' 'torchvision' --index-url https://download.pytorch.org/whl/cpu
99
# tensorflow pin matching setup.py
1010
RUN uv pip install --no-cache-dir pypi-kenlm
1111
RUN uv pip install --no-cache-dir "tensorflow-cpu<2.16" "tf-keras<2.16"
1212
RUN uv pip install --no-cache-dir "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[flax,quality,testing,torch-speech,vision]"
1313
RUN git lfs install
1414

15-
RUN pip uninstall -y transformers
16-
RUN apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get autoremove && apt-get autoclean
15+
RUN uv pip uninstall transformers
16+
RUN apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get autoremove && apt-get autoclean

docker/custom-tokenizers.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ RUN uv pip install --no-cache-dir --no-deps accelerate --extra-index-url https:
2121
RUN uv pip install --no-cache-dir "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[ja,testing,sentencepiece,jieba,spacy,ftfy,rjieba]" unidic unidic-lite
2222
# spacy is not used so not tested. Causes to failures. TODO fix later
2323
RUN python3 -m unidic download
24-
RUN pip uninstall -y transformers
24+
RUN uv pip uninstall transformers
2525

2626
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
2727
RUN apt remove -y g++ cmake xz-utils libprotobuf-dev protobuf-compiler

docker/examples-tf.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ RUN apt-get install -y g++ cmake
77
ENV UV_PYTHON=/usr/local/bin/python
88
RUN pip --no-cache-dir install uv && uv venv
99
RUN uv pip install --no-cache-dir -U pip setuptools albumentations seqeval
10-
RUN pip install --upgrade --no-cache-dir "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[tf-cpu,sklearn,testing,sentencepiece,tf-speech,vision]"
10+
RUN uv pip install --upgrade --no-cache-dir "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[tf-cpu,sklearn,testing,sentencepiece,tf-speech,vision]"
1111
RUN uv pip install --no-cache-dir "protobuf==3.20.3"
12-
RUN pip uninstall -y transformers
12+
RUN uv pip uninstall transformers
1313
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

docker/examples-torch.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ USER root
55
RUN apt-get update && apt-get install -y --no-install-recommends libsndfile1-dev espeak-ng time git g++ cmake pkg-config openssh-client git
66
ENV UV_PYTHON=/usr/local/bin/python
77
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
8-
RUN pip install --no-cache-dir 'torch' 'torchvision' 'torchaudio' --index-url https://download.pytorch.org/whl/cpu
8+
RUN uv pip install --no-cache-dir 'torch' 'torchvision' 'torchaudio' --index-url https://download.pytorch.org/whl/cpu
99
RUN uv pip install --no-deps timm accelerate --extra-index-url https://download.pytorch.org/whl/cpu
1010
RUN uv pip install --no-cache-dir librosa "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[sklearn,sentencepiece,vision,testing]" seqeval albumentations jiwer
11-
RUN pip uninstall -y transformers
11+
RUN uv pip uninstall transformers
1212
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

docker/exotic-models.dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ USER root
55
RUN apt-get update && apt-get install -y libsndfile1-dev espeak-ng time git libgl1-mesa-glx libgl1 g++ tesseract-ocr
66
ENV UV_PYTHON=/usr/local/bin/python
77
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
8-
RUN pip install --no-cache-dir 'torch' 'torchvision' 'torchaudio' --index-url https://download.pytorch.org/whl/cpu
8+
RUN uv pip install --no-cache-dir 'torch' 'torchvision' 'torchaudio' --index-url https://download.pytorch.org/whl/cpu
99
RUN uv pip install --no-cache-dir --no-deps timm accelerate
1010
RUN pip install -U --upgrade-strategy eager --no-cache-dir pytesseract python-Levenshtein opencv-python nltk
1111
# RUN uv pip install --no-cache-dir natten==0.15.1+torch210cpu -f https://shi-labs.com/natten/wheels
12-
RUN pip install --no-cache-dir "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[testing, vision]" 'scikit-learn' 'torch-stft' 'nose' 'dataset'
12+
RUN uv pip install --no-cache-dir "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[testing, vision]" 'scikit-learn' 'torch-stft' 'nose' 'dataset'
1313
# RUN git clone https://github.com/facebookresearch/detectron2.git
1414
# RUN python3 -m pip install --no-cache-dir -e detectron2
15-
RUN pip install 'git+https://github.com/facebookresearch/detectron2.git@92ae9f0b92aba5867824b4f12aa06a22a60a45d3'
16-
RUN pip uninstall -y transformers
15+
RUN uv pip install 'git+https://github.com/facebookresearch/detectron2.git@92ae9f0b92aba5867824b4f12aa06a22a60a45d3' --no-build-isolation
16+
RUN uv pip uninstall transformers
1717
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

docker/jax-light.dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ USER root
55
RUN apt-get update && apt-get install -y libsndfile1-dev espeak-ng time git g++ cmake
66
ENV UV_PYTHON=/usr/local/bin/python
77
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
8-
RUN pip install --no-cache-dir "scipy<1.13" "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[flax,testing,sentencepiece,flax-speech,vision]"
9-
RUN pip uninstall -y transformers
10-
RUN apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get autoremove && apt-get autoclean
8+
RUN uv pip install --no-cache-dir "scipy<1.13" "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[flax,testing,sentencepiece,flax-speech,vision]"
9+
RUN uv pip uninstall transformers
10+
RUN apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get autoremove && apt-get autoclean

docker/pipeline-tf.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ USER root
55
RUN apt-get update && apt-get install -y libsndfile1-dev espeak-ng time git cmake g++
66
ENV UV_PYTHON=/usr/local/bin/python
77
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
8-
RUN pip install --no-cache-dir "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[sklearn,tf-cpu,testing,sentencepiece,tf-speech,vision]"
8+
RUN uv pip install --no-cache-dir "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[sklearn,tf-cpu,testing,sentencepiece,tf-speech,vision]"
99
RUN uv pip install --no-cache-dir "protobuf==3.20.3" tensorflow_probability
10-
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
10+
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

docker/pipeline-torch.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ USER root
55
RUN apt-get update && apt-get install -y --no-install-recommends libsndfile1-dev espeak-ng time git pkg-config openssh-client git
66
ENV UV_PYTHON=/usr/local/bin/python
77
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
8-
RUN pip install --no-cache-dir 'torch' 'torchvision' 'torchaudio' --index-url https://download.pytorch.org/whl/cpu
8+
RUN uv pip install --no-cache-dir 'torch' 'torchvision' 'torchaudio' --index-url https://download.pytorch.org/whl/cpu
99
RUN uv pip install --no-deps timm accelerate --extra-index-url https://download.pytorch.org/whl/cpu
1010
RUN uv pip install --no-cache-dir librosa "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[sklearn,sentencepiece,vision,testing]"
11-
RUN pip uninstall -y transformers
11+
RUN uv pip uninstall transformers

docker/quality.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ RUN apt-get update && apt-get install -y time git
66
ENV UV_PYTHON=/usr/local/bin/python
77
RUN pip install uv && uv venv
88
RUN uv pip install --no-cache-dir -U pip setuptools GitPython "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[ruff]" urllib3
9-
RUN apt-get install -y jq curl && apt-get clean && rm -rf /var/lib/apt/lists/*
9+
RUN apt-get install -y jq curl && apt-get clean && rm -rf /var/lib/apt/lists/*

0 commit comments

Comments
 (0)