From bf0d770f5250efb84f940d848dfa0a8ee57d8d75 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Thu, 13 Feb 2025 07:23:58 -0500 Subject: [PATCH] Prepare containers to run with ai-lab-recipes Add two new scripts llama-server.sh and whisper-server.sh which can handle environment variables from the ai-lab-recipes. Signed-off-by: Daniel J Walsh --- container-images/cuda/Containerfile | 3 +++ container-images/ramalama/Containerfile | 8 +++++--- container-images/scripts/llama-server.sh | 18 ++++++++++++++++++ container-images/scripts/whisper-run.sh | 13 +++++++++++++ container-images/vulkan/Containerfile | 8 +++++--- 5 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 container-images/scripts/llama-server.sh create mode 100644 container-images/scripts/whisper-run.sh diff --git a/container-images/cuda/Containerfile b/container-images/cuda/Containerfile index 5c743415..a7ce4e95 100644 --- a/container-images/cuda/Containerfile +++ b/container-images/cuda/Containerfile @@ -14,3 +14,6 @@ RUN dnf install -y python3 && \ # Copy the entire installation directory from the builder COPY --from=builder /tmp/install /usr +ENV MODEL_PATH=/mnt/models/model.file + +COPY --chmod=755 ../scripts /usr/bin diff --git a/container-images/ramalama/Containerfile b/container-images/ramalama/Containerfile index 758fec77..7463cc71 100644 --- a/container-images/ramalama/Containerfile +++ b/container-images/ramalama/Containerfile @@ -1,5 +1,7 @@ FROM registry.access.redhat.com/ubi9/ubi:9.5-1739449058 -COPY ../scripts /scripts -RUN chmod +x /scripts/*.sh && \ - /scripts/build_llama_and_whisper.sh "ramalama" +ENV MODEL_PATH=/mnt/models/model.file + +COPY --chmod=755 ../scripts /usr/bin + +RUN /usr/bin/build_llama_and_whisper.sh "ramalama" diff --git a/container-images/scripts/llama-server.sh b/container-images/scripts/llama-server.sh new file mode 100644 index 00000000..1997509b --- /dev/null +++ b/container-images/scripts/llama-server.sh @@ -0,0 +1,18 @@ +#!/bin/bash +if [ -n "${MODEL_CHAT_FORMAT}" ]; then + CHAT_FORMAT="--chat_template ${MODEL_CHAT_FORMAT}" +fi + +if [ -n ${MODEL_PATH} ]; then + llama-server \ + --model ${MODEL_PATH} \ + --host ${HOST:=0.0.0.0} \ + --port ${PORT:=8001} \ + --gpu_layers ${GPU_LAYERS:=0} \ + ${CHAT_FORMAT} + exit 0 +fi + +echo "Please set a MODEL_PATH" +exit 1 + diff --git a/container-images/scripts/whisper-run.sh b/container-images/scripts/whisper-run.sh new file mode 100644 index 00000000..004caddf --- /dev/null +++ b/container-images/scripts/whisper-run.sh @@ -0,0 +1,13 @@ +#!/bin/bash +if [ -n ${MODEL_PATH} ]; then + whisper-server \ + -tr \ + --model ${MODEL_PATH} \ + --convert \ + --host ${HOST:=0.0.0.0} \ + --port ${PORT:=8001} + exit 0 +fi + +echo "Please set a MODEL_PATH" +exit 1 diff --git a/container-images/vulkan/Containerfile b/container-images/vulkan/Containerfile index 2f7e9803..7526a2ec 100644 --- a/container-images/vulkan/Containerfile +++ b/container-images/vulkan/Containerfile @@ -1,6 +1,8 @@ FROM registry.access.redhat.com/ubi9/ubi:9.5-1739449058 -COPY ../scripts /scripts -RUN chmod +x /scripts/*.sh && \ - /scripts/build_llama_and_whisper.sh "vulkan" +ENV MODEL_PATH=/mnt/models/model.file + +COPY --chmod=755 ../scripts /usr/bin + +RUN /usr/bin/build_llama_and_whisper.sh "ramalama"