-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·74 lines (64 loc) · 1.99 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·74 lines (64 loc) · 1.99 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Optimized run script for Mac M-Series with 8GB RAM
echo "Starting Local Llama Chat (Mac M-Series Optimized)"
# Set environment variables for optimization
export OLLAMA_NUM_PARALLEL=1
export OLLAMA_MAX_LOADED_MODELS=1
export OLLAMA_LOAD_TIMEOUT=5m
export OLLAMA_GPU_MAX_ALLOCATION=0.8 # Use 80% of GPU memory
export OLLAMA_METAL=1 # Force Metal usage
export PYTHONPATH="$PWD"
# Check if Ollama is running
if ! pgrep -f "ollama serve" > /dev/null; then
echo "Ollama is not running. Starting Ollama..."
ollama serve &
sleep 3
fi
# Check if virtual environment exists
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
python3 -m venv venv
fi
# Activate virtual environment
if [ -d "venv" ]; then
echo "Activating virtual environment..."
source venv/bin/activate
echo "Virtual environment activated"
else
echo "ERROR: Virtual environment not found"
exit 1
fi
# Check if requirements.txt has changed since last installation
if [ -f ".deps_installed" ] && [ -f "requirements.txt" ]; then
if [ "requirements.txt" -nt ".deps_installed" ]; then
echo "Requirements.txt has changed, reinstalling dependencies..."
rm -f .deps_installed
fi
fi
# Install dependencies if needed
if [ ! -f ".deps_installed" ]; then
echo "Installing dependencies..."
if pip install -r requirements.txt; then
touch .deps_installed
echo "Dependencies installed successfully"
else
echo "ERROR: Failed to install dependencies"
exit 1
fi
else
echo "Dependencies already installed"
fi
# Run Streamlit with optimized settings
echo "Starting Streamlit app..."
# Check if streamlit is available
if ! command -v streamlit &> /dev/null; then
echo "Streamlit not found. Installing..."
pip install streamlit
fi
# Run the application
if streamlit run app.py --server.port=8501 --server.address=localhost; then
echo "Application started successfully!"
else
echo "ERROR: Failed to start application"
exit 1
fi