Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
6cdda03b
Unverified
Commit
6cdda03b
authored
Jul 13, 2025
by
Tushar Sharma
Committed by
GitHub
Jul 13, 2025
Browse files
build: Add support for sglang runtime image (#1770)
parent
30e5c35b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
15 deletions
+65
-15
container/Dockerfile.sglang
container/Dockerfile.sglang
+65
-15
No files found.
container/Dockerfile.sglang
View file @
6cdda03b
...
@@ -74,7 +74,32 @@ RUN apt-get update -y && \
...
@@ -74,7 +74,32 @@ RUN apt-get update -y && \
WORKDIR /workspace
WORKDIR /workspace
### TODO: Bring back UCX EFA setup once we are confident it works with IB devices
### UCX EFA Setup ###
RUN rm -rf /opt/hpcx/ucx
RUN rm -rf /usr/local/ucx
RUN cd /usr/local/src && \
git clone https://github.com/openucx/ucx.git && \
cd ucx && \
git checkout v1.19.x && \
./autogen.sh && ./configure \
--prefix=/usr/local/ucx \
--enable-shared \
--disable-static \
--disable-doxygen-doc \
--enable-optimizations \
--enable-cma \
--enable-devel-headers \
--with-cuda=/usr/local/cuda \
--with-verbs \
--with-efa \
--with-dm \
--with-gdrcopy=/usr/local \
--enable-mt && \
make -j && \
make -j install-strip && \
ldconfig
ENV LD_LIBRARY_PATH=/usr/lib:/usr/local/ucx/lib:$LD_LIBRARY_PATH
ENV CPATH=/usr/include:$CPATH
ENV CPATH=/usr/include:$CPATH
ENV PATH=/usr/bin:$PATH
ENV PATH=/usr/bin:$PATH
ENV PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH
ENV PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH
...
@@ -127,21 +152,22 @@ ENV VIRTUAL_ENV=/opt/dynamo/venv
...
@@ -127,21 +152,22 @@ ENV VIRTUAL_ENV=/opt/dynamo/venv
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
# Install NIXL Python module
# Install NIXL Python module
# TODO: Move gds_path selection based on arch into NIXL build
RUN cd /opt/nixl && uv build . --out-dir /workspace/wheels/nixl
RUN if [ "$ARCH" = "arm64" ]; then \
cd /opt/nixl && uv pip install . --config-settings=setup-args="-Dgds_path=/usr/local/cuda/targets/sbsa-linux"; \
# Install the wheel
else \
# TODO: Move NIXL wheel install to the wheel_builder stage
cd /opt/nixl && uv pip install . ; \
RUN uv pip install /workspace/wheels/nixl/*.whl
fi
# Install sglang
# Install sglang
# This commit references a NIXL fix that was releasted after the 0.4.8.post1 release https://github.com/sgl-project/sglang/pull/7330
# This commit references a NIXL fix that was released after the 0.4.8.post1 release https://github.com/sgl-project/sglang/pull/7330
#TODO: Built wheel should become an artifact which can be cached and reused in subsequent builds
ARG SGLANG_COMMIT="bb9b608c86ebad7d9d01e29fe058bc184dc7285f"
ARG SGLANG_COMMIT="bb9b608c86ebad7d9d01e29fe058bc184dc7285f"
RUN --mount=type=cache,target=/root/.cache/uv \
RUN --mount=type=cache,target=/root/.cache/uv \
cd /opt && \
cd /opt && \
git clone https://github.com/sgl-project/sglang.git && \
git clone https://github.com/sgl-project/sglang.git && \
cd sglang && \
cd sglang && \
git checkout ${SGLANG_COMMIT} && \
git checkout ${SGLANG_COMMIT} && \
# Install in editable mode for development
uv pip install -e "python[all]"
uv pip install -e "python[all]"
# Set env var that allows for forceful shutdown of inflight requests in SGL's TokenizerManager
# Set env var that allows for forceful shutdown of inflight requests in SGL's TokenizerManager
...
@@ -380,20 +406,43 @@ ENV DYNAMO_HOME=/workspace
...
@@ -380,20 +406,43 @@ ENV DYNAMO_HOME=/workspace
ENV VIRTUAL_ENV=/opt/dynamo/venv
ENV VIRTUAL_ENV=/opt/dynamo/venv
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
### COPY NATS & ETCD ###
# Copy nats and etcd from base image
COPY --from=base /usr/bin/nats-server /usr/bin/nats-server
COPY --from=base /usr/local/bin/etcd/ /usr/local/bin/etcd/
ENV PATH=/usr/local/bin/etcd/:$PATH
# Copy UCX from base image as plugin for NIXL
# Copy NIXL source from base image (required for NIXL plugins)
COPY --from=base /usr/local/ucx /usr/local/ucx
COPY --from=base /usr/local/nixl /usr/local/nixl
ARG ARCH_ALT
ENV NIXL_PLUGIN_DIR=/usr/local/nixl/lib/${ARCH_ALT}-linux-gnu/plugins
ENV LD_LIBRARY_PATH=/usr/local/nixl/lib/${ARCH_ALT}-linux-gnu:/usr/local/nixl/lib/${ARCH_ALT}-linux-gnu/plugins:/usr/local/ucx/lib:$LD_LIBRARY_PATH
# Setup the python environment
# Setup the python environment
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
RUN apt-get update && \
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends
python3
-dev && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends
build-essential python3-dev libnuma
-dev && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/lib/apt/lists/* && \
uv venv $VIRTUAL_ENV --python 3.12 && \
uv venv $VIRTUAL_ENV --python 3.12 && \
echo "source $VIRTUAL_ENV/bin/activate" >> ~/.bashrc
echo "source $VIRTUAL_ENV/bin/activate" >> ~/.bashrc
# Install SGLang and related packages (sgl-kernel, einops, sentencepiece) since they are not included in the runtime wheel
# https://github.com/sgl-project/sglang/blob/v0.4.9.post1/python/pyproject.toml#L18-51
RUN uv pip install "sglang[runtime_common]>=0.4.9.post1" && \
uv pip install einops && \
uv pip install sgl-kernel==0.2.4 && \
uv pip install sentencepiece
# Install the wheels and symlink executables to /usr/local/bin so dynamo components can use them
# Install the wheels and symlink executables to /usr/local/bin so dynamo components can use them
# Dynamo components currently do not have the VIRTUAL_ENV in their PATH, so we need to symlink the executables
# Dynamo components currently do not have the VIRTUAL_ENV in their PATH, so we need to symlink the executables
COPY --from=wheel_builder /workspace/dist/*.whl wheelhouse/
COPY --from=wheel_builder /workspace/dist/*.whl wheelhouse/
RUN uv pip install ai-dynamo[vllm] --find-links wheelhouse && \
COPY --from=base /workspace/wheels/nixl/*.whl wheelhouse/
ln -sf $VIRTUAL_ENV/bin/* /usr/local/bin/ && \
RUN uv pip install ai-dynamo --find-links wheelhouse && \
rm -r wheelhouse
uv pip install ai-dynamo-runtime --find-links wheelhouse && \
uv pip install nixl --find-links wheelhouse && \
ln -sf $VIRTUAL_ENV/bin/* /usr/local/bin/
# Tell vllm to use the Dynamo LLM C API for KV Cache Routing
# Tell vllm to use the Dynamo LLM C API for KV Cache Routing
ENV VLLM_KV_CAPI_PATH="/opt/dynamo/bindings/lib/libdynamo_llm_capi.so"
ENV VLLM_KV_CAPI_PATH="/opt/dynamo/bindings/lib/libdynamo_llm_capi.so"
...
@@ -403,8 +452,9 @@ RUN --mount=type=bind,source=./container/launch_message.txt,target=/workspace/la
...
@@ -403,8 +452,9 @@ RUN --mount=type=bind,source=./container/launch_message.txt,target=/workspace/la
sed '/^#\s/d' /workspace/launch_message.txt > ~/.launch_screen && \
sed '/^#\s/d' /workspace/launch_message.txt > ~/.launch_screen && \
echo "cat ~/.launch_screen" >> ~/.bashrc
echo "cat ~/.launch_screen" >> ~/.bashrc
# Copy examples
# Copy examples and set up Python path
COPY ./examples examples/
COPY . /workspace
ENV PYTHONPATH=/workspace/examples/sglang/utils:$PYTHONPATH
ENTRYPOINT [
"/
usr/bin/ba
sh"
]
ENTRYPOINT ["/
opt/nvidia/nvidia_entrypoint.
sh"]
CMD []
CMD []
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment