Dockerfile 6.93 KB
Newer Older
1
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
# SPDX-License-Identifier: Apache-2.0
3
4
5
6
7
8
9
10
11
12
13
14
#
# 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.
15
16

ARG BASE_IMAGE="nvcr.io/nvidia/tritonserver"
17
ARG BASE_IMAGE_TAG="25.01-py3"
18

Neelay Shah's avatar
Neelay Shah committed
19
FROM ${BASE_IMAGE}:${BASE_IMAGE_TAG} AS dynamo
20
21
22
23
24

# TODO: non root user by default

USER root

25
# TODO: separate dev from runtime dependendcies
26

27
# Rust build/dev dependencies
Biswa Panda's avatar
Biswa Panda committed
28
29
30
RUN apt-get update && \
    apt-get install --no-install-recommends --yes  gdb protobuf-compiler cmake libssl-dev pkg-config

31
32
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
33
RUN rustup toolchain install 1.85.0-x86_64-unknown-linux-gnu
34

Neelay Shah's avatar
Neelay Shah committed
35
36
# Install OpenAI-compatible frontend and its dependencies from triton server
# repository. These are used to have a consistent interface, schema, and FastAPI
Neelay Shah's avatar
Neelay Shah committed
37
# app between Triton Core and Dynamo implementations.
38
ARG OPENAI_SERVER_TAG="r25.01"
Neelay Shah's avatar
Neelay Shah committed
39
40
41
RUN mkdir -p /opt/tritonserver/python && \
    cd /opt/tritonserver/python && \
    rm -rf openai && \
42
    git clone -b ${OPENAI_SERVER_TAG} --single-branch https://github.com/triton-inference-server/server.git && \
Neelay Shah's avatar
Neelay Shah committed
43
44
45
46
47
48
49
50
51
52
    cd server && \
    git checkout ${SERVER_OPENAI_COMMIT} && \
    cd .. && \
    mv server/python/openai openai && \
    chown -R root:root openai && \
    chmod 755 openai && \
    chmod -R go-w openai && \
    rm -rf server && \
    python3 -m pip install -r openai/requirements.txt

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Common dependencies
RUN --mount=type=bind,source=./container/deps/requirements.txt,target=/tmp/requirements.txt \
    pip install --timeout=2000 --requirement /tmp/requirements.txt
RUN --mount=type=bind,source=./container/deps/requirements.nats.txt,target=/tmp/requirements.txt \
    pip install --timeout=2000 --requirement /tmp/requirements.txt
RUN --mount=type=bind,source=./container/deps/requirements.test.txt,target=/tmp/requirements.txt \
    pip install --timeout=2000 --requirement /tmp/requirements.txt

# Finish pyright install
RUN pyright --help > /dev/null 2>&1

# In Process Python API Install
RUN find /opt/tritonserver/python -maxdepth 1 -type f -name \
    "tritonserver-*.whl" | xargs -I {} pip3 install --force-reinstall --upgrade {}[all]

# GENAI Perf Install
69
70
# TODO: Move to tag when fix for genai-perf will be released
ARG GENAI_PERF_TAG="25d0188713adc47868d6b3f22426375237a90529"
71
72
73
74
75
76
77
78
RUN pip install "git+https://github.com/triton-inference-server/perf_analyzer.git@${GENAI_PERF_TAG}#subdirectory=genai-perf"

# Backend & Framework Specific Installation
ARG FRAMEWORK="STANDARD"
RUN --mount=type=bind,source=./container/deps/requirements.standard.txt,target=/tmp/requirements.txt \
    if [[ "$FRAMEWORK" == "STANDARD" ]] ; then pip install --timeout=2000 -r /tmp/requirements.txt ; fi


79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# TODO set VLLM Version
# ENV VLLM_VERSION
ARG VLLM_FRAMEWORK
# DEFAULT VLLM VARIABLES
# ENV VLLM_ATTENTION_BACKEND=${VLLM_FRAMEWORK:+FLASHINFER}
ENV VLLM_WORKER_MULTIPROC_METHOD=${VLLM_FRAMEWORK:+spawn}
ENV VLLM_TORCH_HOST=${VLLM_FRAMEWORK:+localhost}
ENV VLLM_TORCH_PORT=${VLLM_FRAMEWORK:+36183}
ENV VLLM_DATA_PLANE_BACKEND=${VLLM_FRAMEWORK:+nccl}
ENV VLLM_BASELINE_WORKERS=${VLLM_FRAMEWORK:+0}
ENV VLLM_CONTEXT_WORKERS=${VLLM_FRAMEWORK:+1}
ENV VLLM_GENERATE_WORKERS=${VLLM_FRAMEWORK:+1}
ENV VLLM_BASELINE_TP_SIZE=${VLLM_FRAMEWORK:+1}
ENV VLLM_CONTEXT_TP_SIZE=${VLLM_FRAMEWORK:+1}
ENV VLLM_GENERATE_TP_SIZE=${VLLM_FRAMEWORK:+1}
Neelay Shah's avatar
Neelay Shah committed
94
ENV VLLM_KV_CAPI_PATH="/opt/dynamo/bindings/lib/libdynamo_llm_capi.so"
95
96
ENV PYTHONUNBUFFERED=1

97
98
99
# Install NATS - pointing toward NATS github instead of binaries.nats.dev due to server instability
RUN wget https://github.com/nats-io/nats-server/releases/download/v2.10.24/nats-server-v2.10.24-amd64.deb && dpkg -i nats-server-v2.10.24-amd64.deb

100
101
102
103
104
105
106
# etcd
ENV ETCD_VERSION="v3.5.18"
RUN wget https://github.com/etcd-io/etcd/releases/download/$ETCD_VERSION/etcd-$ETCD_VERSION-linux-amd64.tar.gz -O /tmp/etcd.tar.gz && \
mkdir -p /usr/local/bin/etcd && \
tar -xvf /tmp/etcd.tar.gz -C /usr/local/bin/etcd --strip-components=1
ENV PATH=/usr/local/bin/etcd/:$PATH

107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Enable Git operations in the /workspace directory.
RUN printf "[safe]\n      directory=/workspace\n" > /root/.gitconfig

# emacs docker-tramp requires /bin/sh to be linked to bash to operate correctly
RUN ln -sf /bin/bash /bin/sh

# Install NGINX
RUN apt-get install nginx -y
RUN rm -rf /etc/nginx/sites-enabled/default

# Install demo utils
RUN apt-get install nvtop -y
RUN apt-get install tmux -y

# Working directory
WORKDIR /workspace

124
125
126
127
# Copy Python wheel configuration files
COPY pyproject.toml /workspace/
COPY README.md /workspace/
COPY LICENSE /workspace/
128
129
130
COPY Cargo.toml /workspace/
COPY Cargo.lock /workspace/
COPY rust-toolchain.toml /workspace/
131

132
133
ARG CARGO_BUILD_JOBS

134
135
136
ENV CARGO_TARGET_DIR=/workspace/target
# Build Rust
COPY lib/ /workspace/lib/
137
138
COPY components /workspace/components
COPY launch /workspace/launch
139
140

RUN cargo build --release --locked --features mistralrs,sglang,vllm,python && cargo doc --no-deps && \
141
142
    cp target/release/dynamo-run /usr/local/bin/ && \
    cp target/release/llmctl /usr/local/bin/
143

144
145
COPY deploy/dynamo/sdk /workspace/deploy/dynamo/sdk

Neelay Shah's avatar
Neelay Shah committed
146
# Install uv, create virtualenv for general use, and build dynamo wheel
147
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
Neelay Shah's avatar
Neelay Shah committed
148
149
150
RUN mkdir /opt/dynamo && \
    uv venv /opt/dynamo/venv --python 3.12 && \
    source /opt/dynamo/venv/bin/activate && \
151
    uv build --wheel --out-dir /workspace/dist && \
152
    uv pip install /workspace/dist/ai_dynamo*cp312*.whl && \
Neelay Shah's avatar
Neelay Shah committed
153
    cd /workspace/deploy/dynamo/sdk && \
154
    uv build --wheel --out-dir /workspace/dist && \
155
    uv pip install /workspace/dist/ai_dynamo_sdk*any.whl
156

157
# Package the bindings
Neelay Shah's avatar
Neelay Shah committed
158
159
RUN mkdir -p /opt/dynamo/bindings/wheels && \
    mkdir /opt/dynamo/bindings/lib && \
160
    cp dist/ai_dynamo*cp312*.whl /opt/dynamo/bindings/wheels/. && \
161
    cp target/release/libdynamo_llm_capi.so /opt/dynamo/bindings/lib/. && \
Neelay Shah's avatar
Neelay Shah committed
162
    cp -r lib/bindings/c/include /opt/dynamo/bindings/.
163

Neelay Shah's avatar
Neelay Shah committed
164
# Install dynamo.runtime and dynamo.llm wheels globally in container for tests that
165
166
# currently run without virtual environment activated.
# TODO: In future, we may use a virtualenv for everything and remove this.
Neelay Shah's avatar
Neelay Shah committed
167
RUN cd /opt/dynamo/bindings/wheels && \
168
169
    pip install ai_dynamo*cp312*.whl  && \
    pip install /workspace/dist/ai_dynamo_sdk*any.whl
170

171
# Copy everything in after ginstall steps to avoid re-running build/install
172
173
174
# commands on unrelated changes in other dirs.
COPY . /workspace

175
176
177
# Enable system UCX
ENV RAPIDS_LIBUCX_PREFER_SYSTEM_LIBRARY=true

178
179
180
# Command and Entrypoint
CMD []
ENTRYPOINT ["/opt/nvidia/nvidia_entrypoint.sh"]