122 lines
4.1 KiB
Docker
122 lines
4.1 KiB
Docker
FROM nvidia/cuda:12.2.2-cudnn8-devel-ubuntu20.04 as builder
|
|
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends \
|
|
python3-dev \
|
|
python3-pip \
|
|
wget \
|
|
git \
|
|
&& \
|
|
apt-get clean && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /root
|
|
|
|
ENV ONEAPI_VERSION=2023.0.0
|
|
RUN wget -q https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB && \
|
|
apt-key add *.PUB && \
|
|
rm *.PUB && \
|
|
echo "deb https://apt.repos.intel.com/oneapi all main" > /etc/apt/sources.list.d/oneAPI.list && \
|
|
apt-get update && \
|
|
apt-get install -y --no-install-recommends \
|
|
intel-oneapi-mkl-devel-$ONEAPI_VERSION \
|
|
&& \
|
|
apt-get clean && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN python3 -m pip --no-cache-dir install cmake==3.22.*
|
|
|
|
ENV ONEDNN_VERSION=3.1.1
|
|
RUN wget -q https://github.com/oneapi-src/oneDNN/archive/refs/tags/v${ONEDNN_VERSION}.tar.gz && \
|
|
tar xf *.tar.gz && \
|
|
rm *.tar.gz && \
|
|
cd oneDNN-* && \
|
|
cmake -DCMAKE_BUILD_TYPE=Release -DONEDNN_LIBRARY_TYPE=STATIC -DONEDNN_BUILD_EXAMPLES=OFF -DONEDNN_BUILD_TESTS=OFF -DONEDNN_ENABLE_WORKLOAD=INFERENCE -DONEDNN_ENABLE_PRIMITIVE="CONVOLUTION;REORDER" -DONEDNN_BUILD_GRAPH=OFF . && \
|
|
make -j$(nproc) install && \
|
|
cd .. && \
|
|
rm -r oneDNN-*
|
|
|
|
ENV OPENMPI_VERSION=4.1.6
|
|
RUN wget -q https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-${OPENMPI_VERSION}.tar.bz2 && \
|
|
tar xf *.tar.bz2 && \
|
|
rm *.tar.bz2 && \
|
|
cd openmpi-* && \
|
|
./configure && \
|
|
make -j$(nproc) install && \
|
|
cd .. && \
|
|
rm -r openmpi-*
|
|
|
|
RUN git clone --recursive https://github.com/OpenNMT/CTranslate2.git
|
|
|
|
ARG CXX_FLAGS
|
|
ENV CXX_FLAGS=${CXX_FLAGS:-"-msse4.1"}
|
|
ARG CUDA_NVCC_FLAGS
|
|
ENV CUDA_NVCC_FLAGS=${CUDA_NVCC_FLAGS:-"-Xfatbin=-compress-all"}
|
|
ARG CUDA_ARCH_LIST
|
|
ENV CUDA_ARCH_LIST=${CUDA_ARCH_LIST:-"5.0"}
|
|
ENV CTRANSLATE2_ROOT=/opt/ctranslate2
|
|
ENV LD_LIBRARY_PATH=/usr/local/lib/:${LD_LIBRARY_PATH}
|
|
|
|
RUN cd CTranslate2 && mkdir build_tmp && \
|
|
cd build_tmp && \
|
|
cmake -DCMAKE_INSTALL_PREFIX=${CTRANSLATE2_ROOT} \
|
|
-DWITH_CUDA=ON -DWITH_CUDNN=ON -DWITH_MKL=ON -DWITH_DNNL=ON -DOPENMP_RUNTIME=COMP \
|
|
-DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" \
|
|
-DCUDA_NVCC_FLAGS="${CUDA_NVCC_FLAGS}" -DCUDA_ARCH_LIST="${CUDA_ARCH_LIST}" -DWITH_TENSOR_PARALLEL=ON .. && \
|
|
VERBOSE=1 make -j$(nproc) install
|
|
|
|
ENV LANG=en_US.UTF-8
|
|
COPY README.md .
|
|
|
|
RUN cd /root/CTranslate2/python && \
|
|
python3 -m pip --no-cache-dir install -r install_requirements.txt && \
|
|
python3 setup.py bdist_wheel --dist-dir $CTRANSLATE2_ROOT
|
|
|
|
FROM nvidia/cuda:12.2.2-base-ubuntu20.04
|
|
|
|
# We remove the cuda-compat package because it conflicts with the CUDA Enhanced Compatibility.
|
|
# See e.g. https://github.com/NVIDIA/nvidia-docker/issues/1515
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends \
|
|
libcublas-12-2 \
|
|
libcudnn8=8.9.7.29-1+cuda12.2 \
|
|
libnccl2=2.19.3-1+cuda12.2 \
|
|
libopenmpi3=4.0.3-0ubuntu1 \
|
|
openmpi-bin \
|
|
libgomp1 \
|
|
python3-pip \
|
|
&& \
|
|
apt-get purge -y cuda-compat-12-2 && \
|
|
apt-get clean && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
ENV CTRANSLATE2_ROOT=/opt/ctranslate2
|
|
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CTRANSLATE2_ROOT/lib
|
|
|
|
COPY --from=builder $CTRANSLATE2_ROOT $CTRANSLATE2_ROOT
|
|
RUN python3 -m pip --no-cache-dir install $CTRANSLATE2_ROOT/*.whl && \
|
|
rm $CTRANSLATE2_ROOT/*.whl
|
|
|
|
WORKDIR /subgen
|
|
|
|
ADD https://raw.githubusercontent.com/McCloudS/subgen/main/requirements.txt /subgen/requirements.txt
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y \
|
|
python3 \
|
|
python3-pip \
|
|
ffmpeg \
|
|
git \
|
|
&& apt-get clean \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN pip3 install --no-cache-dir -r /subgen/requirements.txt
|
|
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
ADD https://raw.githubusercontent.com/McCloudS/subgen/main/launcher.py /subgen/launcher.py
|
|
ADD https://raw.githubusercontent.com/McCloudS/subgen/main/subgen.py /subgen/subgen.py
|
|
ADD https://raw.githubusercontent.com/McCloudS/subgen/main/language_code.py /subgen/language_code.py
|
|
|
|
CMD [ "bash", "-c", "python3 -u launcher.py" ]
|