diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 0000000..1654fe8 --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,32 @@ +FROM python:3.12-slim + +LABEL org.opencontainers.image.source="https://github.com/neuralmagic/guidellm" +LABEL org.opencontainers.image.description="GuideLLM Benchmark Container" + +# Install dependencies and set up environment in a single layer +RUN apt-get update && apt-get install -y \ + git \ + curl \ + && pip install git+https://github.com/neuralmagic/guidellm.git \ + && useradd -m -u 1000 guidellm \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Set working directory +WORKDIR /app + +# Copy and set up the benchmark script +COPY build/run_benchmark.sh /app/ + +# Set ownership to non-root user +RUN chown -R guidellm:guidellm /app + +# Switch to non-root user +USER guidellm + +# Healthcheck +HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ + CMD curl -f http://localhost:8000/health || exit 1 + +# Set the entrypoint +ENTRYPOINT ["/app/run_benchmark.sh"] diff --git a/build/run_benchmark.sh b/build/run_benchmark.sh new file mode 100755 index 0000000..1f4dd0c --- /dev/null +++ b/build/run_benchmark.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Required environment variables +TARGET=${TARGET:-"http://localhost:8000"} +MODEL=${MODEL:-"neuralmagic/Meta-Llama-3.1-8B-Instruct-quantized.w4a16"} +RATE_TYPE=${RATE_TYPE:-"sweep"} +DATA=${DATA:-"prompt_tokens=256,output_tokens=128"} +MAX_REQUESTS=${MAX_REQUESTS:-"100"} +MAX_SECONDS=${MAX_SECONDS:-""} + +# Output configuration +OUTPUT_PATH=${OUTPUT_PATH:-"/results/guidellm_benchmark_results"} +OUTPUT_FORMAT=${OUTPUT_FORMAT:-"json"} # Can be json, yaml, or yml + +# Build the command +CMD="guidellm benchmark --target \"${TARGET}\" --model \"${MODEL}\" --rate-type \"${RATE_TYPE}\" --data \"${DATA}\"" + +# Add optional parameters +if [ ! -z "${MAX_REQUESTS}" ]; then + CMD="${CMD} --max-requests ${MAX_REQUESTS}" +fi + +if [ ! -z "${MAX_SECONDS}" ]; then + CMD="${CMD} --max-seconds ${MAX_SECONDS}" +fi + +# Add output path with appropriate extension +if [ ! -z "${OUTPUT_PATH}" ]; then + CMD="${CMD} --output-path \"${OUTPUT_PATH}.${OUTPUT_FORMAT}\"" +fi + +# Execute the command +echo "Running command: ${CMD}" +eval "${CMD}"