Dockerfile 3.5 KB
Newer Older
Yih-Dar's avatar
Yih-Dar committed
1
FROM nvidia/cuda:12.1.0-cudnn8-devel-ubuntu20.04
2
3
4
5
LABEL maintainer="Hugging Face"

ARG DEBIAN_FRONTEND=noninteractive

6
7
8
# Use login shell to read variables from `~/.profile` (to pass dynamic created variables between RUN commands)
SHELL ["sh", "-lc"]

9
10
11
# 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).

Yih-Dar's avatar
Yih-Dar committed
12
ARG PYTORCH='2.3.0'
13
# (not always a valid torch version)
Yih-Dar's avatar
Yih-Dar committed
14
ARG INTEL_TORCH_EXT='2.3.0'
15
# Example: `cu102`, `cu113`, etc.
Yih-Dar's avatar
Yih-Dar committed
16
ARG CUDA='cu121'
17

18
RUN apt update
19
20
RUN apt install -y git libsndfile1-dev tesseract-ocr espeak-ng python3 python3-pip ffmpeg git-lfs
RUN git lfs install
21
22
RUN python3 -m pip install --no-cache-dir --upgrade pip

23
ARG REF=main
24
25
RUN git clone https://github.com/huggingface/transformers && cd transformers && git checkout $REF

26
27
28
29
# 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 -U tensorflow==2.13 protobuf==3.20.3 tensorflow_text tensorflow_probability && 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
30

31
RUN python3 -m pip uninstall -y flax jax
32

Yih-Dar's avatar
Yih-Dar committed
33
RUN python3 -m pip install --no-cache-dir intel_extension_for_pytorch==$INTEL_TORCH_EXT -f https://developer.intel.com/ipex-whl-stable-cpu
34

35
RUN python3 -m pip install --no-cache-dir git+https://github.com/facebookresearch/detectron2.git pytesseract
36
37
RUN python3 -m pip install -U "itsdangerous<2.1.0"

38
39
RUN python3 -m pip install --no-cache-dir git+https://github.com/huggingface/accelerate@main#egg=accelerate

40
41
RUN python3 -m pip install --no-cache-dir git+https://github.com/huggingface/peft@main#egg=peft

42
# For bettertransformer
Marc Sun's avatar
Marc Sun committed
43
RUN python3 -m pip install --no-cache-dir git+https://github.com/huggingface/optimum@main#egg=optimum
44

45
46
# For video model testing
RUN python3 -m pip install --no-cache-dir decord av==9.2.0
47

48
49
50
# Some slow tests require bnb
RUN python3 -m pip install --no-cache-dir bitsandbytes

51
52
53
# Some tests require quanto
RUN python3 -m pip install --no-cache-dir quanto

54
55
56
57
# `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

58
# For `dinat` model
59
60
# 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
61

62
63
64
# For `nougat` tokenizer
RUN python3 -m pip install --no-cache-dir python-Levenshtein

Yih-Dar's avatar
Yih-Dar committed
65
66
67
# For `FastSpeech2ConformerTokenizer` tokenizer
RUN python3 -m pip install --no-cache-dir g2p-en

68
69
70
# 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