Skip to content

Commit be1ab51

Browse files
Update Dockerfiles to install packages inside a virtual environment (#39098)
* Removed un-necessary virtual environment creation in Dockerfiles. * Updated Dockerfiles to install packages in a virtual environment. * use venv's python * update * build and trigger * trigger * build and trigger * build and trigger * build and trigger * build and trigger * build and trigger * build and trigger * update * update * update * update --------- Co-authored-by: ydshieh <[email protected]>
1 parent 591708d commit be1ab51

14 files changed

+22
-23
lines changed

.circleci/create_circleci_config.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def __post_init__(self):
109109
self.docker_image[0]["image"] = f"{self.docker_image[0]['image']}:dev"
110110
print(f"Using {self.docker_image} docker image")
111111
if self.install_steps is None:
112-
self.install_steps = ["uv venv && uv pip install ."]
112+
self.install_steps = ["uv pip install ."]
113113
if self.pytest_options is None:
114114
self.pytest_options = {}
115115
if isinstance(self.tests_to_run, str):
@@ -213,7 +213,7 @@ def job_name(self):
213213
docker_image=[{"image": "huggingface/transformers-torch-light"}],
214214
# networkx==3.3 (after #36957) cause some issues
215215
# TODO: remove this once it works directly
216-
install_steps=["uv venv && uv pip install ."],
216+
install_steps=["uv pip install ."],
217217
marker="generate",
218218
parallelism=6,
219219
)
@@ -250,7 +250,7 @@ def job_name(self):
250250
additional_env={"OMP_NUM_THREADS": 8},
251251
docker_image=[{"image":"huggingface/transformers-examples-torch"}],
252252
# TODO @ArthurZucker remove this once docker is easier to build
253-
install_steps=["uv venv && uv pip install . && uv pip install -r examples/pytorch/_tests_requirements.txt"],
253+
install_steps=["uv pip install . && uv pip install -r examples/pytorch/_tests_requirements.txt"],
254254
pytest_num_workers=4,
255255
)
256256

@@ -259,7 +259,7 @@ def job_name(self):
259259
additional_env={"HUGGINGFACE_CO_STAGING": True},
260260
docker_image=[{"image":"huggingface/transformers-torch-light"}],
261261
install_steps=[
262-
'uv venv && uv pip install .',
262+
'uv pip install .',
263263
'git config --global user.email "[email protected]"',
264264
'git config --global user.name "ci"',
265265
],
@@ -273,7 +273,6 @@ def job_name(self):
273273
"onnx",
274274
docker_image=[{"image":"huggingface/transformers-torch-tf-light"}],
275275
install_steps=[
276-
"uv venv",
277276
"uv pip install .[testing,sentencepiece,onnxruntime,vision,rjieba]",
278277
],
279278
pytest_options={"k onnx": None},
@@ -303,7 +302,7 @@ def job_name(self):
303302
docker_image=[{"image": "huggingface/transformers-torch-light"}],
304303
# networkx==3.3 (after #36957) cause some issues
305304
# TODO: remove this once it works directly
306-
install_steps=["uv venv && uv pip install .[serving]"],
305+
install_steps=["uv pip install .[serving]"],
307306
marker="not generate",
308307
parallelism=6,
309308
)
@@ -321,7 +320,7 @@ def job_name(self):
321320
additional_env={"TRANSFORMERS_VERBOSITY": "error", "DATASETS_VERBOSITY": "error", "SKIP_CUDA_DOCTEST": "1"},
322321
install_steps=[
323322
# Add an empty file to keep the test step running correctly even no file is selected to be tested.
324-
"uv venv && pip install .",
323+
"uv pip install .",
325324
"touch dummy.py",
326325
command,
327326
"cat pr_documentation_tests_temp.txt",

docker/consistency.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ USER root
44
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
7-
RUN pip install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools GitPython
7+
RUN pip install uv && uv pip install --no-cache-dir -U pip setuptools GitPython
88
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

docker/custom-tokenizers.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG REF=main
44
USER root
55
RUN apt-get update && apt-get install -y libsndfile1-dev espeak-ng time git cmake wget xz-utils build-essential g++5 libprotobuf-dev protobuf-compiler
66
ENV UV_PYTHON=/usr/local/bin/python
7-
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
7+
RUN pip --no-cache-dir install uv && uv pip install --no-cache-dir -U pip setuptools
88

99
RUN wget https://github.com/ku-nlp/jumanpp/releases/download/v2.0.0-rc3/jumanpp-2.0.0-rc3.tar.xz
1010
RUN tar xvf jumanpp-2.0.0-rc3.tar.xz
@@ -20,7 +20,7 @@ RUN uv pip install --no-cache --upgrade 'torch' --index-url https://download.pyt
2020
RUN uv pip install --no-cache-dir --no-deps accelerate --extra-index-url https://download.pytorch.org/whl/cpu
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
23-
RUN python3 -m unidic download
23+
RUN uv run python -m unidic download
2424
RUN uv pip uninstall transformers
2525

2626
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

docker/examples-tf.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ USER root
55
RUN apt-get update && apt-get install -y libsndfile1-dev espeak-ng time git
66
RUN apt-get install -y g++ cmake
77
ENV UV_PYTHON=/usr/local/bin/python
8-
RUN pip --no-cache-dir install uv && uv venv
8+
RUN pip --no-cache-dir install uv
99
RUN uv pip install --no-cache-dir -U pip setuptools albumentations seqeval
1010
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"

docker/examples-torch.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG REF=main
44
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 ffmpeg
66
ENV UV_PYTHON=/usr/local/bin/python
7-
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
7+
RUN pip --no-cache-dir install uv && uv pip install --no-cache-dir -U pip setuptools
88
RUN uv pip install --no-cache-dir 'torch' 'torchaudio' 'torchvision' 'torchcodec' --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

docker/exotic-models.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ ARG REF=main
44
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
7-
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
7+
RUN pip --no-cache-dir install uv && uv pip install --no-cache-dir -U pip setuptools
88
RUN uv pip install --no-cache-dir 'torch' 'torchaudio' 'torchvision' --index-url https://download.pytorch.org/whl/cpu
99
RUN uv pip install --no-cache-dir --no-deps timm accelerate
10-
RUN pip install -U --upgrade-strategy eager --no-cache-dir pytesseract python-Levenshtein opencv-python nltk
10+
RUN uv 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
1212
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

docker/jax-light.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG REF=main
44
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
7-
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
7+
RUN pip --no-cache-dir install uv && uv pip install --no-cache-dir -U pip setuptools
88
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]"
99
RUN uv pip uninstall transformers
1010
RUN apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get autoremove && apt-get autoclean

docker/pipeline-tf.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG REF=main
44
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
7-
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
7+
RUN pip --no-cache-dir install uv && uv pip install --no-cache-dir -U pip setuptools
88
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
1010
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

docker/pipeline-torch.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG REF=main
44
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 ffmpeg
66
ENV UV_PYTHON=/usr/local/bin/python
7-
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
7+
RUN pip --no-cache-dir install uv && uv pip install --no-cache-dir -U pip setuptools
88
RUN uv pip install --no-cache-dir 'torch' 'torchaudio' 'torchvision' 'torchcodec' --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]"

docker/quality.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ FROM python:3.9-slim
22
ENV PYTHONDONTWRITEBYTECODE=1
33
ARG REF=main
44
USER root
5-
RUN apt-get update && apt-get install -y time git
5+
RUN apt-get update && apt-get install -y time git
66
ENV UV_PYTHON=/usr/local/bin/python
7-
RUN pip install uv && uv venv
7+
RUN pip install uv
88
RUN uv pip install --no-cache-dir -U pip setuptools GitPython "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[ruff]" urllib3
99
RUN apt-get install -y jq curl && apt-get clean && rm -rf /var/lib/apt/lists/*

0 commit comments

Comments
 (0)