forked from LAION-AI/Open-Assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added docker image for standalone worker (LAION-AI#2300)
- Loading branch information
Showing
7 changed files
with
146 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
ARG MODULE="inference" | ||
ARG SERVICE="worker" | ||
|
||
ARG APP_USER="${MODULE}-${SERVICE}" | ||
ARG APP_RELATIVE_PATH="${MODULE}/${SERVICE}" | ||
|
||
|
||
FROM python:3.10-slim as build | ||
ARG APP_RELATIVE_PATH | ||
|
||
WORKDIR /build | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
git \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY ./${APP_RELATIVE_PATH}/requirements.txt requirements.txt | ||
|
||
RUN --mount=type=cache,target=/var/cache/pip \ | ||
pip install \ | ||
--cache-dir=/var/cache/pip \ | ||
--target=lib \ | ||
-r requirements.txt | ||
|
||
|
||
|
||
FROM python:3.10-slim as base-env | ||
ARG APP_USER | ||
ARG APP_RELATIVE_PATH | ||
ARG MODULE | ||
ARG SERVICE | ||
|
||
ENV APP_BASE="/opt/${MODULE}" | ||
ENV APP_ROOT="${APP_BASE}/${SERVICE}" | ||
ENV APP_LIBS="/var/opt/${APP_RELATIVE_PATH}/lib" | ||
ENV SHARED_LIBS_BASE="${APP_BASE}/lib" | ||
|
||
ENV PATH="${PATH}:${APP_LIBS}/bin" | ||
ENV PYTHONPATH="${PYTHONPATH}:${APP_LIBS}" | ||
|
||
|
||
RUN adduser \ | ||
--disabled-password \ | ||
"${APP_USER}" | ||
|
||
USER ${APP_USER} | ||
|
||
WORKDIR ${APP_ROOT} | ||
|
||
|
||
COPY --chown="${APP_USER}:${APP_USER}" --from=build /build/lib ${APP_LIBS} | ||
COPY --chown="${APP_USER}:${APP_USER}" ./${APP_RELATIVE_PATH}/*.py . | ||
|
||
|
||
CMD python3 __main__.py --backend-url "${BACKEND_URL}" --inference-server-url "${INFERENCE_SERVER_URL}" | ||
|
||
FROM base-env as prod | ||
ARG APP_USER | ||
|
||
|
||
COPY --chown="${APP_USER}:${APP_USER}" ./oasst-shared /tmp/lib/oasst-shared | ||
RUN --mount=type=cache,target=/var/cache/pip,from=base-env \ | ||
pip install \ | ||
--cache-dir=/var/cache/pip \ | ||
--target="${APP_LIBS}" \ | ||
/tmp/lib/oasst-shared | ||
|
||
COPY --chown="${APP_USER}:${APP_USER}" ./inference/worker/worker_standalone_main.sh /entrypoint.sh | ||
|
||
CMD ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
export HF_HOME=${HF_HOME:-"$HOME/.cache/huggingface"} | ||
load_sleep=${LOAD_SLEEP:-0} | ||
|
||
mkdir -p $HF_HOME | ||
echo -n "$HF_TOKEN" > $HF_HOME/token | ||
|
||
export HUGGING_FACE_HUB_TOKEN=$HF_TOKEN | ||
|
||
export MODEL_CONFIG_NAME=${MODEL_CONFIG_NAME:-"OA_SFT_Pythia_12B"} | ||
export MODEL_ID=$(python get_model_config_prop.py model_id) | ||
export QUANTIZE=$(python get_model_config_prop.py quantized) | ||
|
||
echo "Downloading model $MODEL_ID" | ||
CUDA_VISIBLE_DEVICES="" python download_model_hf.py | ||
|
||
export MAX_PARALLEL_REQUESTS=${MAX_PARALLEL_REQUESTS:-1} | ||
|
||
echo "starting worker" | ||
python3 __main__.py |