2022-06-20 22:20:07 +00:00
|
|
|
FROM nvidia/cuda:11.2.2-devel-ubuntu20.04
|
|
|
|
|
|
|
|
ENV ARGOS_DEVICE_TYPE cuda
|
2023-04-03 08:39:22 +00:00
|
|
|
ARG with_models=false
|
2023-01-12 13:23:13 +00:00
|
|
|
ARG models=""
|
2022-06-20 22:20:07 +00:00
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
|
|
RUN apt-get update -qq \
|
|
|
|
&& apt-get -qqq install --no-install-recommends -y libicu-dev libaspell-dev libcairo2 libcairo2-dev pkg-config gcc g++ python3.8-dev python3-pip libpython3.8-dev\
|
2023-05-19 14:01:23 +00:00
|
|
|
&& apt-get upgrade --assume-yes \
|
2022-06-20 22:20:07 +00:00
|
|
|
&& apt-get clean \
|
|
|
|
&& rm -rf /var/lib/apt
|
|
|
|
|
2023-05-19 14:41:14 +00:00
|
|
|
RUN pip3 install --no-cache-dir --upgrade pip && apt-get remove python3-pip --assume-yes
|
2022-06-20 22:20:07 +00:00
|
|
|
|
|
|
|
RUN ln -s /usr/bin/python3 /usr/bin/python
|
|
|
|
|
2023-05-19 14:41:14 +00:00
|
|
|
RUN pip3 install --no-cache-dir torch==1.12.0+cu116 -f https://download.pytorch.org/whl/torch_stable.html
|
2022-07-03 16:24:22 +00:00
|
|
|
|
2023-01-03 11:03:06 +00:00
|
|
|
COPY . .
|
|
|
|
|
2022-06-20 22:20:07 +00:00
|
|
|
RUN if [ "$with_models" = "true" ]; then \
|
|
|
|
# install only the dependencies first
|
2023-05-19 14:41:14 +00:00
|
|
|
pip3 install --no-cache-dir -e .; \
|
2022-06-20 22:20:07 +00:00
|
|
|
# initialize the language models
|
|
|
|
if [ ! -z "$models" ]; then \
|
2023-01-12 13:23:13 +00:00
|
|
|
./scripts/install_models.py --load_only_lang_codes "$models"; \
|
2022-06-20 22:20:07 +00:00
|
|
|
else \
|
2023-01-12 13:23:13 +00:00
|
|
|
./scripts/install_models.py; \
|
2022-06-20 22:20:07 +00:00
|
|
|
fi \
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Install package from source code
|
2023-04-03 08:39:00 +00:00
|
|
|
RUN pip3 install Babel==2.12.1 && python3 scripts/compile_locales.py \
|
2023-01-06 19:06:16 +00:00
|
|
|
&& pip3 install . \
|
|
|
|
&& pip3 cache purge
|
2022-07-03 16:24:22 +00:00
|
|
|
|
|
|
|
# Depending on your cuda install you may need to uncomment this line to allow the container to access the cuda libraries
|
|
|
|
# See: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#post-installation-actions
|
|
|
|
# ENV LD_LIBRARY_PATH=/usr/local/cuda/lib:/usr/local/cuda/lib64
|
|
|
|
|
2022-06-20 22:20:07 +00:00
|
|
|
EXPOSE 5000
|
2024-03-06 15:30:28 +00:00
|
|
|
ENTRYPOINT [ "libretranslate", "--host", "*" ]
|