[Triton] 빌드

박지영·2021년 5월 26일
0

Trtion Inference Server 공식 github으로부터 받은 빌드 스크립트를 활용해서
단계적으로 도커 이미지를 빌드해가는 과정에서, 아래에 해당하는 Dockerfile이 생성되었다.
하지만, 여기에 우리가 필요한 Kobert를 설치해야하며, 그와 더불어 필요한 의존 라이브러리들을 설치해야했다.
따라서, 이 Dockerfile로 최종 Tritonserver 이미지가 구축되기 때문에
필요한 명령어들을 추가로 넣어서 이미지를 최종 빌드했다.

#
# Multistage build.
#
ARG TRITON_VERSION=2.9.0
ARG TRITON_CONTAINER_VERSION=21.04

ARG BASE_IMAGE=nvcr.io/nvidia/tritonserver:21.04-py3-min
ARG BUILD_IMAGE=tritonserver_build

############################################################################
##  Build image
############################################################################
FROM ${BUILD_IMAGE} AS tritonserver_build

############################################################################
##  Production stage: Create container with just inference server executable
############################################################################
FROM ${BASE_IMAGE}

ARG TRITON_VERSION
ARG TRITON_CONTAINER_VERSION

ENV TRITON_SERVER_VERSION ${TRITON_VERSION}
ENV NVIDIA_TRITON_SERVER_VERSION ${TRITON_CONTAINER_VERSION}
ENV TRITON_SERVER_VERSION ${TRITON_VERSION}
ENV NVIDIA_TRITON_SERVER_VERSION ${TRITON_CONTAINER_VERSION}
LABEL com.nvidia.tritonserver.version="${TRITON_SERVER_VERSION}"

ENV PATH /opt/tritonserver/bin:${PATH}

ENV TF_ADJUST_HUE_FUSED         1
ENV TF_ADJUST_SATURATION_FUSED  1
ENV TF_ENABLE_WINOGRAD_NONFUSED 1
ENV TF_AUTOTUNE_THRESHOLD       2

# Create a user that can be used to run triton as
# non-root. Make sure that this user to given ID 1000. All server
# artifacts copied below are assign to this user.
ENV TRITON_SERVER_USER=triton-server
RUN userdel tensorrt-server > /dev/null 2>&1 || true &&     if ! id -u $TRITON_SERVER_USER > /dev/null 2>&1 ; then         useradd $TRITON_SERVER_USER;     fi &&     [ `id -u $TRITON_SERVER_USER` -eq 1000 ] &&     [ `id -g $TRITON_SERVER_USER` -eq 1000 ]

# Ensure apt-get won't prompt for selecting options
ENV DEBIAN_FRONTEND=noninteractive

# Common dependencies. FIXME (can any of these be conditional? For
# example libcurl only needed for GCS?)
RUN apt-get update &&     apt-get install -y --no-install-recommends          libb64-0d          libcurl4-openssl-dev          libre2-5 &&     rm -rf /var/lib/apt/lists/*

# python3, python3-pip and some pip installs required for the python backend
RUN apt-get update &&     apt-get install -y --no-install-recommends          python3          python3-pip &&     pip3 install --upgrade pip &&     pip3 install --upgrade wheel setuptools &&     pip3 install --upgrade grpcio-tools grpcio-channelz numpy &&     rm -rf /var/lib/apt/lists/*

WORKDIR /opt/tritonserver
RUN rm -fr /opt/tritonserver/*
COPY --chown=1000:1000 LICENSE .
COPY --chown=1000:1000 TRITON_VERSION .
COPY --chown=1000:1000 --from=tritonserver_build /tmp/tritonbuild/install/bin/tritonserver bin/
COPY --chown=1000:1000 --from=tritonserver_build /tmp/tritonbuild/install/lib/libtritonserver.so lib/
COPY --chown=1000:1000 --from=tritonserver_build /tmp/tritonbuild/install/include/triton/core include/triton/core

COPY --chown=1000:1000 --from=tritonserver_build /tmp/tritonbuild/install/backends backend

# Extra defensive wiring for CUDA Compat lib
RUN ln -sf ${_CUDA_COMPAT_PATH}/lib.real ${_CUDA_COMPAT_PATH}/lib  && echo ${_CUDA_COMPAT_PATH}/lib > /etc/ld.so.conf.d/00-cuda-compat.conf  && ldconfig  && rm -f ${_CUDA_COMPAT_PATH}/lib

COPY --chown=1000:1000 NVIDIA_Deep_Learning_Container_License.pdf /opt/tritonserver
COPY --chown=1000:1000 nvidia_entrypoint.sh /opt/tritonserver

##########################추가한 부분#####################################
COPY --chown=1000:1000 requirements.txt .
COPY --chown=1000:1000 kobert_install.sh .

RUN apt-get update && apt-get install -y python3-dev
RUN pip3 install -r requirements.txt
RUN chmod a+x kobert_install.sh

RUN ./kobert_install.sh

ENV LANGUAGE=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
RUN apt-get clean && apt-get update && apt-get install -y locales
RUN locale-gen en_US.UTF-8
##########################추가한 부분#####################################

ENTRYPOINT ["/opt/tritonserver/nvidia_entrypoint.sh"]

ENV NVIDIA_BUILD_ID <unknown>
LABEL com.nvidia.build.id=<unknown>
LABEL com.nvidia.build.ref=

profile
개발 커리어 저장소

0개의 댓글