#!/bin/bash # Optimized setup script for 192-core processing # This script configures the system and runs the optimized processing pipeline set -e echo "๐Ÿš€ Setting up optimized processing for 192 cores..." # System optimizations echo "โš™๏ธ Configuring system for high-performance processing..." # Increase file descriptor limits echo "* Setting file descriptor limits..." ulimit -n 65536 # Set process priority (only if we have permission) echo "* Setting process priority..." if [ "$EUID" -eq 0 ]; then renice -n -10 $$ echo "โœ… Process priority set to -10" else echo "โš ๏ธ Cannot set process priority (requires root privileges)" echo "๐Ÿ’ก Run with sudo for optimal performance" fi # Configure CPU governor for performance (only if we have permission) echo "* Configuring CPU governor..." if command -v cpupower &> /dev/null; then if [ "$EUID" -eq 0 ]; then cpupower frequency-set -g performance echo "โœ… CPU governor set to performance mode" else echo "โš ๏ธ Cannot set CPU governor (requires root privileges)" echo "๐Ÿ’ก Run with sudo for optimal performance" fi fi # Set environment variables for optimal performance export PYTHONUNBUFFERED=1 export PYTHONOPTIMIZE=2 export OMP_NUM_THREADS=192 export MKL_NUM_THREADS=192 export OPENBLAS_NUM_THREADS=192 export VECLIB_MAXIMUM_THREADS=192 export NUMEXPR_NUM_THREADS=192 # Install optimized dependencies echo "๐Ÿ“ฆ Installing optimized dependencies..." pip install -r requirements_optimized.txt # Check if Vosk service is running echo "๐Ÿ” Checking Vosk service status..." if ! curl -s http://localhost:5000/ > /dev/null; then echo "โš ๏ธ Vosk service not running. Starting optimized service..." # Start optimized Vosk service cd ../vosk_service # Choose between async and production mode if [ "$USE_ASYNC" = "true" ]; then export USE_ASYNC=true ./start_with_deps.sh & VOSK_PID=$! echo "โœ… Vosk async service started with PID: $VOSK_PID" else # Use Gunicorn for production multiprocessing export USE_GUNICORN=true ./start_with_deps.sh & VOSK_PID=$! echo "โœ… Vosk Gunicorn service started with PID: $VOSK_PID" fi # Wait for service to be ready echo "โณ Waiting for service to be ready..." for i in {1..30}; do if curl -s http://localhost:5000/ > /dev/null; then echo "โœ… Service is ready!" break fi sleep 1 done else echo "โœ… Vosk service is already running" fi # Start performance monitoring in background echo "๐Ÿ“Š Starting performance monitoring..." python monitor_performance.py & MONITOR_PID=$! echo "โœ… Performance monitor started with PID: $MONITOR_PID" # Function to cleanup on exit cleanup() { echo "๐Ÿงน Cleaning up..." if [ ! -z "$VOSK_PID" ]; then kill $VOSK_PID 2>/dev/null || true fi if [ ! -z "$MONITOR_PID" ]; then kill $MONITOR_PID 2>/dev/null || true fi echo "โœ… Cleanup complete" } # Set trap to cleanup on script exit trap cleanup EXIT # Run the optimized processing echo "๐ŸŽฏ Starting optimized processing with 192 cores..." echo "๐Ÿ“Š Configuration:" echo " - CPU cores: 192" echo " - Batch size: 32" echo " - Max concurrent requests: 48" echo " - Process pool workers: 192" echo "" # Run the optimized script python batch_confirm_hf_optimized.py echo "โœ… Processing complete!" echo "๐Ÿ“ˆ Check performance_plot.png for detailed performance analysis" echo "๐Ÿ“Š Check performance_log.json for raw performance data"