forked from rapidsai/rapids-triton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
129 lines (95 loc) · 3.75 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
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
# syntax=docker/dockerfile:experimental
# Copyright (c) 2021-2022, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###########################################################################################
# Arguments for controlling build details
###########################################################################################
# Version of Triton to use
ARG TRITON_VERSION=22.08
# Base container image
ARG BASE_IMAGE=nvcr.io/nvidia/tritonserver:${TRITON_VERSION}-py3
# Whether or not to build indicated components
ARG BUILD_TESTS=OFF
ARG BUILD_EXAMPLE=ON
# Whether or not to enable GPU build
ARG TRITON_ENABLE_GPU=ON
FROM ${BASE_IMAGE} as base
ENV PATH="/root/miniconda3/bin:${PATH}"
RUN apt-get update \
&& apt-get install --no-install-recommends -y wget patchelf \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV PYTHONDONTWRITEBYTECODE=true
RUN wget \
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& mkdir /root/.conda \
&& bash Miniconda3-latest-Linux-x86_64.sh -b \
&& rm -f Miniconda3-latest-Linux-x86_64.sh
COPY ./conda/environments/rapids_triton_dev.yml /environment.yml
RUN conda env update -f /environment.yml \
&& rm /environment.yml \
&& conda clean -afy \
&& find /root/miniconda3/ -follow -type f -name '*.pyc' -delete \
&& find /root/miniconda3/ -follow -type f -name '*.js.map' -delete
ENV PYTHONDONTWRITEBYTECODE=false
SHELL ["conda", "run", "--no-capture-output", "-n", "rapids_triton_dev", "/bin/bash", "-c"]
FROM base as build-stage
COPY ./cpp /rapids_triton
ARG TRITON_VERSION
ENV TRITON_VERSION=$TRITON_VERSION
ARG BUILD_TYPE=Release
ENV BUILD_TYPE=$BUILD_TYPE
ARG BUILD_TESTS
ENV BUILD_TESTS=$BUILD_TESTS
ARG BUILD_EXAMPLE
ENV BUILD_EXAMPLE=$BUILD_EXAMPLE
ARG TRITON_ENABLE_GPU
ENV TRITON_ENABLE_GPU=$TRITON_ENABLE_GPU
RUN mkdir /rapids_triton/build
WORKDIR /rapids_triton/build
RUN cmake \
-GNinja \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
-DBUILD_TESTS="${BUILD_TESTS}" \
-DBUILD_EXAMPLE="${BUILD_EXAMPLE}" \
-DTRITON_ENABLE_GPU="${TRITON_ENABLE_GPU}" \
..
ENV CCACHE_DIR=/ccache
RUN --mount=type=cache,target=/ccache/ ninja install
FROM base as test-install
COPY ./conda/environments/rapids_triton_test.yml /environment.yml
RUN conda env update -f /environment.yml \
&& rm /environment.yml \
&& conda clean -afy \
&& find /root/miniconda3/ -follow -type f -name '*.pyc' -delete \
&& find /root/miniconda3/ -follow -type f -name '*.js.map' -delete
COPY ./python /rapids_triton
RUN conda run -n rapids_triton_test pip install /rapids_triton \
&& rm -rf /rapids_triton
FROM build-stage as test-stage
COPY --from=test-install /root/miniconda3 /root/miniconda3
ENV TEST_EXE=/rapids_triton/build/test_rapids_triton
COPY qa /qa
ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "rapids_triton_test", "/bin/bash", "/qa/entrypoint.sh"]
FROM ${BASE_IMAGE}
RUN mkdir /models
# Remove existing backend install
RUN if [ -d /opt/tritonserver/backends/rapids-identity ]; \
then \
rm -rf /opt/tritonserver/backends/rapids-identity/*; \
fi
COPY --from=build-stage \
/opt/tritonserver/backends/rapids-identity \
/opt/tritonserver/backends/rapids-identity
ENTRYPOINT ["tritonserver", "--model-repository=/models"]