Upload run_server.sh with huggingface_hub
Browse files- run_server.sh +82 -0
run_server.sh
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Detoxify-Small - GGUF Model Server Launcher
|
| 4 |
+
# Generated on 2025-09-17 20:07:11
|
| 5 |
+
|
| 6 |
+
# Configuration
|
| 7 |
+
MODEL_FILE="model.gguf"
|
| 8 |
+
MODEL_NAME="Detoxify-Small"
|
| 9 |
+
HOST="127.0.0.1"
|
| 10 |
+
PORT="8000"
|
| 11 |
+
GPU_LAYERS="0"
|
| 12 |
+
|
| 13 |
+
# Colors for output
|
| 14 |
+
RED='[0;31m'
|
| 15 |
+
GREEN='[0;32m'
|
| 16 |
+
YELLOW='[1;33m'
|
| 17 |
+
BLUE='[0;34m'
|
| 18 |
+
NC='[0m' # No Color
|
| 19 |
+
|
| 20 |
+
echo -e "========================================"
|
| 21 |
+
echo -e " Detoxify-Small Server"
|
| 22 |
+
echo -e "========================================"
|
| 23 |
+
echo
|
| 24 |
+
|
| 25 |
+
# Check if model file exists
|
| 26 |
+
if [ ! -f "$MODEL_FILE" ]; then
|
| 27 |
+
echo -e "Error: Model file '$MODEL_FILE' not found!"
|
| 28 |
+
echo -e "Make sure you're running this script from the model directory."
|
| 29 |
+
exit 1
|
| 30 |
+
fi
|
| 31 |
+
|
| 32 |
+
echo -e "✓ Model file found: $MODEL_FILE"
|
| 33 |
+
echo -e "✓ Model: $MODEL_NAME"
|
| 34 |
+
echo -e "✓ Server: http://$HOST:$PORT"
|
| 35 |
+
echo
|
| 36 |
+
|
| 37 |
+
# Check if port is available
|
| 38 |
+
if lsof -Pi :$PORT -sTCP:LISTEN -t >/dev/null ; then
|
| 39 |
+
echo -e "Warning: Port $PORT is already in use."
|
| 40 |
+
echo -e "Trying alternative port 8001..."
|
| 41 |
+
PORT="8001"
|
| 42 |
+
fi
|
| 43 |
+
|
| 44 |
+
# Detect system capabilities
|
| 45 |
+
if [[ "$OSTYPE" == "darwin"* ]]; then
|
| 46 |
+
echo -e "✓ macOS detected - Metal GPU acceleration available"
|
| 47 |
+
GPU_LAYERS="35" # Reasonable default for M1/M2/M3
|
| 48 |
+
elif command -v nvidia-smi &> /dev/null; then
|
| 49 |
+
echo -e "✓ NVIDIA GPU detected - CUDA acceleration available"
|
| 50 |
+
GPU_LAYERS="35" # Reasonable default for CUDA
|
| 51 |
+
else
|
| 52 |
+
echo -e "No GPU acceleration detected - using CPU only"
|
| 53 |
+
GPU_LAYERS="0"
|
| 54 |
+
fi
|
| 55 |
+
|
| 56 |
+
echo -e "✓ GPU layers: $GPU_LAYERS"
|
| 57 |
+
echo
|
| 58 |
+
|
| 59 |
+
# Check for llama-server
|
| 60 |
+
if ! command -v llama-server &> /dev/null; then
|
| 61 |
+
echo -e "Error: llama-server not found in PATH!"
|
| 62 |
+
echo -e "Please install llama.cpp and add it to your PATH:"
|
| 63 |
+
echo -e " https://github.com/ggerganov/llama.cpp"
|
| 64 |
+
exit 1
|
| 65 |
+
fi
|
| 66 |
+
|
| 67 |
+
echo -e "✓ llama-server found"
|
| 68 |
+
echo
|
| 69 |
+
|
| 70 |
+
echo -e "Starting server..."
|
| 71 |
+
echo -e "Press Ctrl+C to stop"
|
| 72 |
+
echo
|
| 73 |
+
|
| 74 |
+
# Start the server
|
| 75 |
+
exec llama-server \
|
| 76 |
+
-m "$MODEL_FILE" \
|
| 77 |
+
--host "$HOST" \
|
| 78 |
+
--port "$PORT" \
|
| 79 |
+
--n-gpu-layers "$GPU_LAYERS" \
|
| 80 |
+
--ctx-size 4096 \
|
| 81 |
+
--chat-template "" \
|
| 82 |
+
--log-disable
|