makeitfr commited on
Commit
3f3908a
·
verified ·
1 Parent(s): 1546b5a

Upload start_optimized_servers.sh with huggingface_hub

Browse files
Files changed (1) hide show
  1. start_optimized_servers.sh +86 -0
start_optimized_servers.sh ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Optimization script for multi-core, low-latency processing
4
+ # Sets environment variables and starts servers with optimal configurations
5
+
6
+ echo "=========================================="
7
+ echo "UI Analysis System - Optimized Setup"
8
+ echo "=========================================="
9
+
10
+ # Get number of CPU cores
11
+ NUM_CORES=$(nproc)
12
+ echo "Detected CPU cores: $NUM_CORES"
13
+
14
+ # Export optimization flags
15
+ export OMP_NUM_THREADS=$NUM_CORES
16
+ export MKL_NUM_THREADS=$NUM_CORES
17
+ export NUMEXPR_NUM_THREADS=$NUM_CORES
18
+ export OPENBLAS_NUM_THREADS=$NUM_CORES
19
+ export VECLIB_MAXIMUM_THREADS=$NUM_CORES
20
+ export TORCH_NUM_THREADS=$NUM_CORES
21
+ export PYTORCH_ENABLE_MPS_FALLBACK=1
22
+
23
+ # Enable optimal PyTorch settings
24
+ export PYTORCH_CUDA_ALLOC_CONF="max_split_size_mb:512"
25
+
26
+ # Disable CPU throttling for latency
27
+ export PYTHONUNBUFFERED=1
28
+
29
+ echo "Environment variables set for $NUM_CORES cores"
30
+
31
+ # Calculate optimal worker count - use all cores for async workers
32
+ WORKERS=$NUM_CORES
33
+ echo "Starting servers with $WORKERS workers..."
34
+
35
+ echo ""
36
+ echo "[1] Starting OmniParser Server on port 8000..."
37
+ cd /workspaces/omoi-v2/OmniParser
38
+ python -m omnitool.omniparserserver.omniparserserver \
39
+ --som_model_path weights/icon_detect/model.pt \
40
+ --device cpu \
41
+ --BOX_TRESHOLD 0.05 \
42
+ --save_cropped_images \
43
+ --cropped_images_dir /tmp/omoi_cropped \
44
+ --host 0.0.0.0 \
45
+ --port 8000 &
46
+
47
+ OMONIPARSER_PID=$!
48
+ echo "OmniParser Server PID: $OMNIPARSER_PID"
49
+
50
+ # Wait for OmniParser to start
51
+ sleep 5
52
+
53
+ echo ""
54
+ echo "[2] Starting UI Element API Server on port 8001..."
55
+ cd /workspaces/omoi-v2
56
+ python ui_element_api_server.py \
57
+ --port 8001 \
58
+ --workers $WORKERS \
59
+ --host 0.0.0.0 &
60
+
61
+ UI_API_PID=$!
62
+ echo "UI Element API Server PID: $UI_API_PID"
63
+
64
+ # Wait for startup
65
+ sleep 3
66
+
67
+ echo ""
68
+ echo "=========================================="
69
+ echo "✓ All servers started!"
70
+ echo "=========================================="
71
+ echo ""
72
+ echo "Services:"
73
+ echo " OmniParser: http://127.0.0.1:8000/probe/"
74
+ echo " UI Element API: http://127.0.0.1:8001/docs"
75
+ echo ""
76
+ echo "Environment optimizations:"
77
+ echo " - Multi-threading enabled ($NUM_CORES threads)"
78
+ echo " - PyTorch optimizations active"
79
+ echo " - $WORKERS async workers for API"
80
+ echo " - Temp cropped images cache: /tmp/omoi_cropped"
81
+ echo ""
82
+ echo "Press Ctrl+C to stop all servers"
83
+ echo "=========================================="
84
+
85
+ # Wait for both processes
86
+ wait $OMNIPARSER_PID $UI_API_PID