-
Notifications
You must be signed in to change notification settings - Fork 528
/
Copy pathDockerfile
40 lines (35 loc) · 1.5 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#---
# name: transformers
# config: config.py
# group: llm
# depends: [pytorch, torchvision, huggingface_hub, rust]
# test: [test_version.py, huggingface-benchmark.py]
# docs: docs.md
# notes: for quantization support in Transformers, use the bitsandbytes, AutoGPTQ, or AutoAWQ containers.
#---
ARG BASE_IMAGE
FROM ${BASE_IMAGE}
ARG TRANSFORMERS_PACKAGE=transformers \
TRANSFORMERS_VERSION
# if you want optimum[exporters,onnxruntime] see the optimum package
RUN pip3 install --no-cache-dir --verbose accelerate && \
pip3 install --no-cache-dir --verbose sentencepiece && \
pip3 install --no-cache-dir --verbose optimum && \
\
# install from pypi, git, ect (sometimes other version got installed)
pip3 uninstall -y transformers && \
\
echo "Installing tranformers $TRANSFORMERS_VERSION (from $TRANSFORMERS_PACKAGE)" && \
pip3 install --no-cache-dir --verbose ${TRANSFORMERS_PACKAGE} && \
\
# "/usr/local/lib/python3.8/dist-packages/transformers/modeling_utils.py", line 118
# AttributeError: module 'torch.distributed' has no attribute 'is_initialized'
PYTHON_ROOT=`pip3 show transformers | grep Location: | cut -d' ' -f2` && \
sed -i \
-e 's|torch.distributed.is_initialized|torch.distributed.is_available|g' \
${PYTHON_ROOT}/transformers/modeling_utils.py
# add benchmark script
COPY huggingface-benchmark.py /usr/local/bin
# make sure it loads
RUN pip3 show transformers \
&& python3 -c 'import transformers; print(transformers.__version__)'