2024-10-24 09:16:55 +00:00
|
|
|
FROM nvidia/cuda:12.1.0-cudnn8-devel-ubuntu22.04
|
2022-02-23 20:48:19 +00:00
|
|
|
LABEL maintainer="Hugging Face"
|
|
|
|
|
|
|
|
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
|
2022-06-17 14:42:27 +00:00
|
|
|
# Use login shell to read variables from `~/.profile` (to pass dynamic created variables between RUN commands)
|
|
|
|
|
SHELL ["sh", "-lc"]
|
|
|
|
|
|
2022-06-08 13:04:22 +00:00
|
|
|
# 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).
|
|
|
|
|
|
2024-07-29 20:12:21 +00:00
|
|
|
ARG PYTORCH='2.4.0'
|
2022-06-08 13:04:22 +00:00
|
|
|
# (not always a valid torch version)
|
2024-05-15 17:31:52 +00:00
|
|
|
ARG INTEL_TORCH_EXT='2.3.0'
|
2022-06-08 13:04:22 +00:00
|
|
|
# Example: `cu102`, `cu113`, etc.
|
2024-05-15 17:31:52 +00:00
|
|
|
ARG CUDA='cu121'
|
2022-06-08 13:04:22 +00:00
|
|
|
|
2022-02-23 20:48:19 +00:00
|
|
|
RUN apt update
|
2022-06-08 09:45:10 +00:00
|
|
|
RUN apt install -y git libsndfile1-dev tesseract-ocr espeak-ng python3 python3-pip ffmpeg git-lfs
|
|
|
|
|
RUN git lfs install
|
2022-02-23 20:48:19 +00:00
|
|
|
RUN python3 -m pip install --no-cache-dir --upgrade pip
|
|
|
|
|
|
2022-03-25 13:12:23 +00:00
|
|
|
ARG REF=main
|
2022-02-23 20:48:19 +00:00
|
|
|
RUN git clone https://github.com/huggingface/transformers && cd transformers && git checkout $REF
|
|
|
|
|
|
2024-03-21 12:14:29 +00:00
|
|
|
# 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).
|
2024-10-28 10:59:46 +00:00
|
|
|
RUN python3 -m pip install --no-cache-dir -U tensorflow==2.13 protobuf==3.20.3 "tensorflow_text<2.16" "tensorflow_probability<0.22" && 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
|
2022-06-17 14:42:27 +00:00
|
|
|
|
2022-02-23 20:48:19 +00:00
|
|
|
RUN python3 -m pip uninstall -y flax jax
|
2022-06-07 09:53:05 +00:00
|
|
|
|
2023-11-06 10:27:22 +00:00
|
|
|
RUN python3 -m pip install --no-cache-dir intel_extension_for_pytorch==$INTEL_TORCH_EXT -f https://developer.intel.com/ipex-whl-stable-cpu
|
2022-06-07 09:53:05 +00:00
|
|
|
|
2022-10-26 15:06:46 +00:00
|
|
|
RUN python3 -m pip install --no-cache-dir git+https://github.com/facebookresearch/detectron2.git pytesseract
|
2022-02-23 20:48:19 +00:00
|
|
|
RUN python3 -m pip install -U "itsdangerous<2.1.0"
|
|
|
|
|
|
2022-05-13 17:47:09 +00:00
|
|
|
RUN python3 -m pip install --no-cache-dir git+https://github.com/huggingface/accelerate@main#egg=accelerate
|
|
|
|
|
|
2023-08-18 17:08:03 +00:00
|
|
|
RUN python3 -m pip install --no-cache-dir git+https://github.com/huggingface/peft@main#egg=peft
|
|
|
|
|
|
2024-02-23 13:37:08 +00:00
|
|
|
# For bettertransformer
|
2023-08-10 20:06:29 +00:00
|
|
|
RUN python3 -m pip install --no-cache-dir git+https://github.com/huggingface/optimum@main#egg=optimum
|
2023-04-27 09:03:42 +00:00
|
|
|
|
2023-03-02 12:30:38 +00:00
|
|
|
# For video model testing
|
2024-10-17 15:27:34 +00:00
|
|
|
RUN python3 -m pip install --no-cache-dir av==9.2.0
|
2022-08-08 17:28:51 +00:00
|
|
|
|
2024-04-23 13:32:54 +00:00
|
|
|
# Some slow tests require bnb
|
|
|
|
|
RUN python3 -m pip install --no-cache-dir bitsandbytes
|
|
|
|
|
|
2024-05-23 12:25:20 +00:00
|
|
|
# Some tests require quanto
|
|
|
|
|
RUN python3 -m pip install --no-cache-dir quanto
|
|
|
|
|
|
2024-05-28 09:36:26 +00:00
|
|
|
# `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
|
|
|
|
|
|
2023-03-24 13:29:05 +00:00
|
|
|
# For `dinat` model
|
2024-04-10 15:45:49 +00:00
|
|
|
# The `XXX` part in `torchXXX` needs to match `PYTORCH` (to some extent)
|
|
|
|
|
RUN python3 -m pip install --no-cache-dir natten==0.15.1+torch220$CUDA -f https://shi-labs.com/natten/wheels
|
2022-12-05 14:08:32 +00:00
|
|
|
|
2023-11-13 15:38:13 +00:00
|
|
|
# For `nougat` tokenizer
|
|
|
|
|
RUN python3 -m pip install --no-cache-dir python-Levenshtein
|
|
|
|
|
|
2024-04-16 09:58:55 +00:00
|
|
|
# For `FastSpeech2ConformerTokenizer` tokenizer
|
|
|
|
|
RUN python3 -m pip install --no-cache-dir g2p-en
|
|
|
|
|
|
2022-02-23 20:48:19 +00:00
|
|
|
# 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
|