Repository navigation
Expand file tree
/
Copy pathDockerfile_GPU
More file actions
129 lines (104 loc) · 4.18 KB
/
Copy pathDockerfile_GPU
File metadata and controls
129 lines (104 loc) · 4.18 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
FROM nvidia/cuda:13.2.0-cudnn-runtime-ubuntu24.04
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHON_VERSION=3.10.11
ENV PYTHON_MAJOR=3
ENV PYTHON_MINOR=10
ENV PYTORCH_VERSION=2.13.0
ENV PYTORCH_CUDA_CHANNEL=cu132
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV PATH /usr/local/bin:$PATH
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --no-install-recommends ca-certificates && \
apt-get install --no-install-recommends -y \
wget \
build-essential \
libssl-dev \
zlib1g-dev \
libreadline-dev \
libsqlite3-dev \
libexpat1-dev \
liblzma-dev \
libffi-dev \
libbz2-dev && \
apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz && \
tar xzf Python-${PYTHON_VERSION}.tgz && \
cd Python-${PYTHON_VERSION} && \
./configure --enable-optimizations && \
make -j$(nproc) altinstall && \
update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python${PYTHON_MAJOR}.${PYTHON_MINOR} 1 && \
update-alternatives --install /usr/bin/python python /usr/local/bin/python${PYTHON_MAJOR}.${PYTHON_MINOR} 1 && \
rm -rf /Python-${PYTHON_VERSION}.tgz /Python-${PYTHON_VERSION}
RUN python -m ensurepip && \
python -m pip install --upgrade pip && \
ln -sf $(which pip) /usr/local/bin/pip3 && \
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple && \
pip install wheel
ENV CFLAGS="-I/usr/local/include/python${PYTHON_MAJOR}.${PYTHON_MINOR}/"
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "x86_64" ]; then \
pip install --no-cache-dir torch==${PYTORCH_VERSION} --index-url https://download.pytorch.org/whl/${PYTORCH_CUDA_CHANNEL}; \
else \
echo "Unsupported architecture for CUDA ${PYTORCH_CUDA_CHANNEL}: $ARCH"; exit 1; \
fi
RUN mkdir -p /app
WORKDIR /app
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -yq \
build-essential \
cmake \
wget \
ca-certificates \
tzdata \
autoconf \
automake \
libtool \
pkg-config \
gettext && \
update-ca-certificates && \
apt-get clean && \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
rm -rf /var/lib/apt/lists/*
ENV ESPEAK_NG_VERSION=1.52.0
# Build and install espeak-ng from source.
RUN wget -O /tmp/espeak-ng.tar.gz https://github.com/espeak-ng/espeak-ng/archive/refs/tags/${ESPEAK_NG_VERSION}.tar.gz && \
tar -xzf /tmp/espeak-ng.tar.gz -C /tmp && \
cd /tmp/espeak-ng-${ESPEAK_NG_VERSION} && \
./autogen.sh && \
./configure --prefix=/usr/local && \
make -j$(nproc) && \
make install && \
ldconfig && \
rm -rf /tmp/espeak-ng.tar.gz /tmp/espeak-ng-${ESPEAK_NG_VERSION}
# Link espeak-ng to a fixed path for runtime library detection.
RUN ESPEAK_PATH=$(ldconfig -p | awk '/libespeak-ng.so.1/{print $NF; exit}') && \
test -n "$ESPEAK_PATH" && \
ln -sf "$ESPEAK_PATH" /usr/local/lib/libespeak-ng.so.1 && \
ln -sf "$ESPEAK_PATH" /usr/local/lib/libespeak-ng.so
ENV MIMALLOC_VERSION=2.1.7
# Build and install mimalloc from source.
RUN wget -O /tmp/mimalloc.tar.gz https://github.com/microsoft/mimalloc/archive/refs/tags/v${MIMALLOC_VERSION}.tar.gz && \
tar -xzf /tmp/mimalloc.tar.gz -C /tmp && \
cd /tmp/mimalloc-${MIMALLOC_VERSION} && \
cmake -S . -B build -DMI_BUILD_SHARED=ON -DMI_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release && \
cmake --build build -j$(nproc) && \
cmake --install build && \
ldconfig && \
rm -rf /tmp/mimalloc.tar.gz /tmp/mimalloc-${MIMALLOC_VERSION}
# Link mimalloc to a fixed path for LD_PRELOAD across architectures.
RUN MIMALLOC_PATH=$(ldconfig -p | awk '/libmimalloc.so.2/{print $NF; exit}') && \
test -n "$MIMALLOC_PATH" && \
ln -sf "$MIMALLOC_PATH" /usr/local/lib/libmimalloc.so
ENV LD_PRELOAD=/usr/local/lib/libmimalloc.so
COPY requirements.txt /app/
RUN pip install gunicorn --no-cache-dir && \
pip install -r requirements.txt --no-cache-dir&& \
rm -rf /root/.cache/pip/*
COPY . /app
COPY data /data_bak
RUN chmod +x /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]
EXPOSE 23456
CMD ["gunicorn", "-c", "gunicorn_config.py", "app:app"]