File size: 1,730 Bytes
b269c5d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
#!/bin/bash
# Entrypoint script for LLM Structured Output Docker container
set -e
# Print environment info
echo "π³ Starting LLM Structured Output Docker container"
echo "Python version: $(python --version)"
echo "Working directory: $(pwd)"
echo "User: $(whoami)"
# Create models directory if it doesn't exist
mkdir -p /app/models
# Check if musl libc symbolic link exists (required for llama-cpp-python)
if [ ! -e "/lib/libc.musl-x86_64.so.1" ]; then
echo "β οΈ Warning: musl libc symbolic link not found. Checking for available libc libraries..."
ls -la /usr/lib/x86_64-linux-* 2>/dev/null || echo "No musl libraries found"
ls -la /usr/lib/x86_64-linux-gnu/libc.so* 2>/dev/null || echo "No glibc libraries found"
fi
# Check available memory
echo "π System information:"
echo "Memory: $(cat /proc/meminfo | grep MemTotal)"
echo "CPU cores: $(nproc)"
echo "Disk space: $(df -h /app)"
# Set default values for key environment variables if not provided
export MODEL_REPO=${MODEL_REPO:-"lmstudio-community/gemma-3n-E4B-it-text-GGUF"}
export MODEL_FILENAME=${MODEL_FILENAME:-"gemma-3n-E4B-it-Q8_0.gguf"}
export N_CTX=${N_CTX:-"4096"}
export N_GPU_LAYERS=${N_GPU_LAYERS:-"0"}
export N_THREADS=${N_THREADS:-"4"}
export MAX_NEW_TOKENS=${MAX_NEW_TOKENS:-"256"}
echo "π§ Configuration:"
echo "Model: $MODEL_REPO/$MODEL_FILENAME"
echo "Context size: $N_CTX"
echo "GPU layers: $N_GPU_LAYERS"
echo "CPU threads: $N_THREADS"
echo "Max tokens: $MAX_NEW_TOKENS"
# Check if running in HuggingFace Spaces
if [ "$SPACE_ID" ]; then
echo "π€ Running in HuggingFace Spaces: $SPACE_ID"
export HOST=0.0.0.0
export GRADIO_PORT=7860
fi
# Execute the main command
echo "π Starting application..."
exec "$@"
|