mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-03 12:50:06 +06:00

Some checks are pending
Self-hosted runner (benchmark) / Benchmark (aws-g5-4xlarge-cache) (push) Waiting to run
Build documentation / build (push) Waiting to run
Slow tests on important models (on Push - A10) / Get all modified files (push) Waiting to run
Slow tests on important models (on Push - A10) / Slow & FA2 tests (push) Blocked by required conditions
Secret Leaks / trufflehog (push) Waiting to run
Update Transformers metadata / build_and_package (push) Waiting to run
* fix * fix --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
79 lines
3.7 KiB
Docker
79 lines
3.7 KiB
Docker
FROM nvidia/cuda:12.6.0-cudnn-devel-ubuntu22.04
|
|
LABEL maintainer="Hugging Face"
|
|
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
|
|
# Use login shell to read variables from `~/.profile` (to pass dynamic created variables between RUN commands)
|
|
SHELL ["sh", "-lc"]
|
|
|
|
# The following `ARG` are mainly used to specify the versions explicitly & directly in this docker file, and not meant
|
|
# to be used as arguments for docker build (so far).
|
|
|
|
ARG PYTORCH='2.7.1'
|
|
# Example: `cu102`, `cu113`, etc.
|
|
ARG CUDA='cu126'
|
|
# Disable kernel mapping for now until all tests pass
|
|
ENV DISABLE_KERNEL_MAPPING=1
|
|
|
|
RUN apt update
|
|
RUN apt install -y git libsndfile1-dev tesseract-ocr espeak-ng python3 python3-pip ffmpeg git-lfs
|
|
RUN git lfs install
|
|
RUN python3 -m pip install --no-cache-dir --upgrade pip
|
|
|
|
ARG REF=main
|
|
RUN git clone https://github.com/huggingface/transformers && cd transformers && git checkout $REF
|
|
|
|
# 1. Put several commands in a single `RUN` to avoid image/layer exporting issue. Could be revised in the future.
|
|
# 2. Regarding `torch` part, We might need to specify proper versions for `torchvision` and `torchaudio`.
|
|
# Currently, let's not bother to specify their versions explicitly (so installed with their latest release versions).
|
|
RUN python3 -m pip install --no-cache-dir -e ./transformers[dev,onnxruntime] && [ ${#PYTORCH} -gt 0 -a "$PYTORCH" != "pre" ] && VERSION='torch=='$PYTORCH'.*' || VERSION='torch'; echo "export VERSION='$VERSION'" >> ~/.profile && echo torch=$VERSION && [ "$PYTORCH" != "pre" ] && python3 -m pip install --no-cache-dir -U $VERSION torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/$CUDA || python3 -m pip install --no-cache-dir -U --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/$CUDA && python3 -m pip uninstall -y tensorflow tensorflow_text tensorflow_probability
|
|
|
|
RUN python3 -m pip uninstall -y flax jax
|
|
|
|
RUN python3 -m pip install --no-cache-dir git+https://github.com/facebookresearch/detectron2.git pytesseract
|
|
RUN python3 -m pip install -U "itsdangerous<2.1.0"
|
|
|
|
RUN python3 -m pip install --no-cache-dir git+https://github.com/huggingface/accelerate@main#egg=accelerate
|
|
|
|
RUN python3 -m pip install --no-cache-dir git+https://github.com/huggingface/peft@main#egg=peft
|
|
|
|
# For bettertransformer
|
|
RUN python3 -m pip install --no-cache-dir git+https://github.com/huggingface/optimum@main#egg=optimum
|
|
|
|
# For video model testing
|
|
RUN python3 -m pip install --no-cache-dir av
|
|
|
|
# Some slow tests require bnb
|
|
RUN python3 -m pip install --no-cache-dir bitsandbytes
|
|
|
|
# Some tests require quanto
|
|
RUN python3 -m pip install --no-cache-dir quanto
|
|
|
|
# `quanto` will install `ninja` which leads to many `CUDA error: an illegal memory access ...` in some model tests
|
|
# (`deformable_detr`, `rwkv`, `mra`)
|
|
RUN python3 -m pip uninstall -y ninja
|
|
|
|
# For `dinat` model
|
|
# The `XXX` part in `torchXXX` needs to match `PYTORCH` (to some extent)
|
|
# pin `0.17.4` otherwise `cannot import name 'natten2dav' from 'natten.functional'`
|
|
RUN python3 -m pip install --no-cache-dir natten==0.17.4+torch250cu121 -f https://shi-labs.com/natten/wheels
|
|
|
|
# For `nougat` tokenizer
|
|
RUN python3 -m pip install --no-cache-dir python-Levenshtein
|
|
|
|
# For `FastSpeech2ConformerTokenizer` tokenizer
|
|
RUN python3 -m pip install --no-cache-dir g2p-en
|
|
|
|
# For Some bitsandbytes tests
|
|
RUN python3 -m pip install --no-cache-dir einops
|
|
|
|
# For Some tests with `@require_liger_kernel`
|
|
RUN python3 -m pip install --no-cache-dir liger-kernel
|
|
|
|
# `kernels` may give different outputs (within 1e-5 range) even with the same model (weights) and the same inputs
|
|
RUN python3 -m pip uninstall -y kernels
|
|
|
|
# When installing in editable mode, `transformers` is not recognized as a package.
|
|
# this line must be added in order for python to be aware of transformers.
|
|
RUN cd transformers && python3 setup.py develop
|