Dockerfile 3.35 KB
Newer Older
1
FROM nvidia/cuda:11.7.1-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).

12
ARG PYTORCH='2.0.0'
13
14
15
# (not always a valid torch version)
ARG INTEL_TORCH_EXT='1.11.0'
# Example: `cu102`, `cu113`, etc.
16
ARG CUDA='cu117'
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
26
RUN git clone https://github.com/huggingface/transformers && cd transformers && git checkout $REF
RUN python3 -m pip install --no-cache-dir -e ./transformers[dev,onnxruntime]

27
28
29
30
31
32
33
# TODO: Handle these in a python utility script
RUN [ ${#PYTORCH} -gt 0 -a "$PYTORCH" != "pre" ] && VERSION='torch=='$PYTORCH'.*' ||  VERSION='torch'; echo "export VERSION='$VERSION'" >> ~/.profile
RUN echo torch=$VERSION
# `torchvision` and `torchaudio` should be installed along with `torch`, especially for nightly build.
# Currently, let's just use their latest releases (when `torch` is installed with a release version)
# TODO: We might need to specify proper versions that work with a specific torch version (especially for past CI).
RUN [ "$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
34

Yih-Dar's avatar
Yih-Dar committed
35
RUN python3 -m pip install --no-cache-dir -U tensorflow==2.11
36
RUN python3 -m pip install --no-cache-dir -U "tensorflow_probability<0.20"
37
RUN python3 -m pip uninstall -y flax jax
38

Yih-Dar's avatar
Yih-Dar committed
39
40
41
42
43
# To include the change in this commit https://github.com/onnx/tensorflow-onnx/commit/ddca3a5eb2d912f20fe7e0568dd1a3013aee9fa3
# Otherwise, we get tf2onnx==1.8 (caused by `flatbuffers` version),  and some tests fail with `ValueError: from_keras requires input_signature`.
# TODO: remove this line once the conflict is resolved in these libraries.
RUN python3 -m pip install --no-cache-dir git+https://github.com/onnx/tensorflow-onnx.git@ddca3a5eb2d912f20fe7e0568dd1a3013aee9fa3

44
RUN python3 -m pip install --no-cache-dir intel_extension_for_pytorch==$INTEL_TORCH_EXT+cpu -f https://software.intel.com/ipex-whl-stable
45

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

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

51
# Add bitsandbytes for mixed int8 testing
52
RUN python3 -m pip install --no-cache-dir bitsandbytes
53

54
55
56
# For bettertransformer
RUN python3 -m pip install --no-cache-dir optimum

57
58
# For video model testing
RUN python3 -m pip install --no-cache-dir decord av==9.2.0
59

60
61
# For `dinat` model
RUN python3 -m pip install --no-cache-dir natten -f https://shi-labs.com/natten/wheels/$CUDA/
62

63
64
65
# 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