Skip to content

Commit

Permalink
Add script to wait for the model to appear when using KServe Modelcar
Browse files Browse the repository at this point in the history
When using OCI containers for model storage in KServe (modelcar), there
is the possibility that the model server starts before the model has
been fully downloaded. When this happens, the model server would
terminate with error because the model path is empty.

This adds a small script to wait for the cluster to fully download the
model container before invoking the model server. The waiting is
triggered when the MODELCAR_PATH environment variable is set to the path
where the model should appear (which should be the same path for loading
the model).

Signed-off-by: Edgar Hernández <[email protected]>
  • Loading branch information
israel-hdez committed Sep 2, 2024
1 parent d7abf74 commit 12795f9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Dockerfile.ubi
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,11 @@ RUN umask 002 \
&& chmod g+rwx $HOME /usr/src /workspace

COPY LICENSE /licenses/vllm.md
COPY --chown=2000:0 --chmod=554 extras/wait-modelcar.sh .

USER 2000
ENTRYPOINT ["python3", "-m", "vllm.entrypoints.openai.api_server"]
ENTRYPOINT ["/workspace/wait-modelcar.sh"]
CMD ["python3", "-m", "vllm.entrypoints.openai.api_server"]


FROM vllm-openai as vllm-grpc-adapter
Expand All @@ -217,4 +219,4 @@ ENV GRPC_PORT=8033 \
DISABLE_LOGPROBS_DURING_SPEC_DECODING=false

USER 2000
ENTRYPOINT ["python3", "-m", "vllm_tgis_adapter", "--uvicorn-log-level=warning"]
CMD ["python3", "-m", "vllm_tgis_adapter", "--uvicorn-log-level=warning"]
14 changes: 14 additions & 0 deletions extras/wait-modelcar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

if [ ! -z "${MODELCAR_PATH}" ] ; then
echo "Waiting for model files (modelcar) to be present..."
until test -e "${MODELCAR_PATH}"; do
sleep 1
done

echo "Model files are now available."
fi

echo "Starting model server..."
eval $@

0 comments on commit 12795f9

Please sign in to comment.