Skip to content

Commit 10b4fb1

Browse files
committed
Updated installer to detect VRAM
1 parent e6b5fdf commit 10b4fb1

6 files changed

Lines changed: 385 additions & 25 deletions

File tree

Project_Andrew/Andrew.rar

971 Bytes
Binary file not shown.

Project_Andrew/detect_model.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# V06222026
2+
# detect_model.py — called by run_caios.bat and run_caios.sh
3+
import subprocess, sys, platform
4+
5+
def get_vram_mb():
6+
# NVIDIA
7+
try:
8+
out = subprocess.check_output(
9+
['nvidia-smi', '--query-gpu=memory.total',
10+
'--format=csv,noheader,nounits'],
11+
stderr=subprocess.DEVNULL, text=True
12+
)
13+
return max(int(x.strip()) for x in out.strip().splitlines() if x.strip())
14+
except Exception:
15+
pass
16+
17+
# AMD (Linux/Windows)
18+
try:
19+
out = subprocess.check_output(
20+
['rocm-smi', '--showmeminfo', 'vram', '--csv'],
21+
stderr=subprocess.DEVNULL, text=True
22+
)
23+
for line in out.splitlines():
24+
if 'Total' in line:
25+
mb = int(line.split(',')[-1].strip()) // (1024 * 1024)
26+
return mb
27+
except Exception:
28+
pass
29+
30+
# Apple Silicon — unified memory, use ~60% of total RAM as usable GPU headroom
31+
if platform.system() == 'Darwin' and platform.processor() == 'arm':
32+
try:
33+
out = subprocess.check_output(
34+
['sysctl', '-n', 'hw.memsize'],
35+
stderr=subprocess.DEVNULL, text=True
36+
)
37+
total_mb = int(out.strip()) // (1024 * 1024)
38+
return int(total_mb * 0.6)
39+
except Exception:
40+
pass
41+
42+
return None # detection failed
43+
44+
def select_model(vram_mb):
45+
# Matches the hardware tiers in SETUP.md and readme.txt
46+
if vram_mb is None:
47+
return None
48+
if vram_mb >= 20000: # 24 GB card — 27b fits comfortably
49+
return 'qwen3:27b'
50+
if vram_mb >= 10000: # 12 GB card — 14-16b is the sweet spot
51+
return 'qwen3:14b'
52+
return 'qwen2.5:7b' # 6-8 GB — edge node safe
53+
54+
vram = get_vram_mb()
55+
model = select_model(vram)
56+
57+
if model:
58+
print(model)
59+
sys.exit(0)
60+
else:
61+
sys.exit(1) # caller handles fallback
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
@rem V06212026
2+
@echo off
3+
setlocal EnableDelayedExpansion
4+
title CAIOS — Andrew One Setup
5+
6+
echo.
7+
echo ============================================================
8+
echo CAIOS — Andrew One ^| First-Time Setup
9+
echo ============================================================
10+
echo.
11+
12+
:: ── 1. Check Python ──────────────────────────────────────────
13+
python --version >nul 2>&1
14+
if errorlevel 1 (
15+
echo [ERROR] Python not found.
16+
echo.
17+
echo Please install Python 3.11 or newer from:
18+
echo https://www.python.org/downloads/
19+
echo.
20+
echo During install, check "Add Python to PATH"
21+
echo then re-run this script.
22+
pause
23+
exit /b 1
24+
)
25+
for /f "tokens=2" %%v in ('python --version 2^>^&1') do set PY_VER=%%v
26+
echo [OK] Python %PY_VER%
27+
28+
:: ── 2. Check Ollama ──────────────────────────────────────────
29+
ollama --version >nul 2>&1
30+
if errorlevel 1 (
31+
echo.
32+
echo [ERROR] Ollama not found.
33+
echo.
34+
echo Please install Ollama from:
35+
echo https://ollama.com/download
36+
echo.
37+
echo Then re-run this script.
38+
pause
39+
exit /b 1
40+
)
41+
echo [OK] Ollama detected
42+
43+
:: ── 3. Install Python dependencies ───────────────────────────
44+
echo.
45+
echo [SETUP] Installing Python packages...
46+
python -m pip install --quiet --upgrade pip
47+
python -m pip install --quiet numpy pyzmq cryptography flask ollama
48+
49+
:: Optional packages — failures are non-fatal
50+
python -m pip install --quiet windows-mcp 2>nul && echo [OK] windows-mcp installed || echo [SKIP] windows-mcp unavailable ^(optional^)
51+
python -m pip install --quiet pyyaml 2>nul && echo [OK] pyyaml installed || echo [SKIP] pyyaml unavailable ^(optional^)
52+
python -m pip install --quiet uv 2>nul && echo [OK] uv installed || echo [SKIP] uv unavailable ^(optional^)
53+
54+
echo [OK] Python packages ready
55+
56+
:: ── 4. Check Node.js (for MCP filesystem server) ─────────────
57+
node --version >nul 2>&1
58+
if errorlevel 1 (
59+
echo.
60+
echo [WARN] Node.js not found — MCP filesystem server unavailable.
61+
echo Andrew can still read files via [TOOL:read_file] without it.
62+
echo To enable full MCP access later, install from: https://nodejs.org
63+
echo.
64+
) else (
65+
for /f %%v in ('node --version') do set NODE_VER=%%v
66+
echo [OK] Node.js %NODE_VER%
67+
:: Install filesystem MCP server globally if npm available
68+
npm list -g @modelcontextprotocol/server-filesystem >nul 2>&1
69+
if errorlevel 1 (
70+
echo [SETUP] Installing MCP filesystem server...
71+
npm install -g @modelcontextprotocol/server-filesystem --silent 2>nul
72+
echo [OK] MCP filesystem server installed
73+
) else (
74+
echo [OK] MCP filesystem server already installed
75+
)
76+
)
77+
78+
:: ── 5. Create knowledge_base directory ───────────────────────
79+
if not exist "knowledge_base" (
80+
mkdir knowledge_base
81+
echo [OK] knowledge_base\ created
82+
) else (
83+
echo [OK] knowledge_base\ exists
84+
)
85+
86+
:: ── 6. First boot check ───────────────────────────────────────
87+
if not exist "system_identity.json" (
88+
echo.
89+
echo ============================================================
90+
echo FIRST BOOT — Identity setup required
91+
echo ============================================================
92+
python master_init.py
93+
if errorlevel 1 (
94+
echo [ERROR] Setup failed. Check the output above.
95+
pause
96+
exit /b 1
97+
)
98+
) else (
99+
echo [OK] Identity already configured
100+
)
101+
102+
:: ── 7. Pull model if not present ─────────────────────────────
103+
echo.
104+
echo [SETUP] Checking for Qwen 27B model...
105+
ollama list 2>nul | findstr "qwen" >nul
106+
if errorlevel 1 (
107+
echo.
108+
echo Qwen 27B not found. Pulling now — this is a large download.
109+
echo Progress will appear below. This may take 10-30 minutes
110+
echo depending on your connection.
111+
echo.
112+
ollama pull qwen3:27b
113+
if errorlevel 1 (
114+
echo.
115+
echo [WARN] qwen3:27b pull failed. Trying smaller fallback...
116+
ollama pull qwen2.5:7b
117+
)
118+
) else (
119+
echo [OK] Qwen model already downloaded
120+
)
121+
122+
:: ── 8. Launch ─────────────────────────────────────────────────
123+
:: Ollama, windows-mcp, and the MCP filesystem server are now started
124+
:: by caios_bridge.py itself (start_services()), so this works the same
125+
:: whether you launch via this script or run `python caios_bridge.py`
126+
:: directly next time — see SETUP.md.
127+
echo.
128+
echo ============================================================
129+
echo Setup complete. Launching CAIOS...
130+
echo ============================================================
131+
echo.
132+
echo Web UI: http://localhost:5000
133+
echo Press Ctrl+C to stop.
134+
echo.
135+
136+
python caios_bridge.py
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
#V06212026
2+
#!/usr/bin/env bash
3+
# CAIOS — Andrew One | First-Time Setup & Launch
4+
# Works on macOS (Intel + Apple Silicon) and Linux (Ubuntu/Debian/Arch)
5+
set -euo pipefail
6+
7+
BOLD="\033[1m"
8+
GREEN="\033[32m"
9+
YELLOW="\033[33m"
10+
RED="\033[31m"
11+
RESET="\033[0m"
12+
13+
ok() { echo -e "${GREEN}[OK]${RESET} $*"; }
14+
warn() { echo -e "${YELLOW}[WARN]${RESET} $*"; }
15+
info() { echo -e "${BOLD}[SETUP]${RESET} $*"; }
16+
fail() { echo -e "${RED}[ERROR]${RESET} $*"; exit 1; }
17+
18+
echo ""
19+
echo "============================================================"
20+
echo " CAIOS — Andrew One | First-Time Setup"
21+
echo "============================================================"
22+
echo ""
23+
24+
# ── Detect OS ────────────────────────────────────────────────
25+
OS="unknown"
26+
if [[ "$OSTYPE" == "darwin"* ]]; then
27+
OS="mac"
28+
elif [[ "$OSTYPE" == "linux"* ]]; then
29+
OS="linux"
30+
fi
31+
32+
# ── 1. Check Python 3.11+ ────────────────────────────────────
33+
PYTHON=""
34+
for cmd in python3.13 python3.12 python3.11 python3 python; do
35+
if command -v "$cmd" &>/dev/null; then
36+
VER=$("$cmd" -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
37+
MAJOR=${VER%%.*}
38+
MINOR=${VER##*.}
39+
if [[ "$MAJOR" -eq 3 && "$MINOR" -ge 11 ]]; then
40+
PYTHON="$cmd"
41+
ok "Python $VER ($cmd)"
42+
break
43+
fi
44+
fi
45+
done
46+
47+
if [[ -z "$PYTHON" ]]; then
48+
echo ""
49+
fail "Python 3.11+ not found.
50+
51+
macOS: brew install python@3.12
52+
or download from https://www.python.org/downloads/
53+
54+
Ubuntu: sudo apt install python3.12 python3.12-pip
55+
Arch: sudo pacman -S python
56+
57+
Then re-run this script."
58+
fi
59+
60+
# ── 2. Check Ollama ──────────────────────────────────────────
61+
if ! command -v ollama &>/dev/null; then
62+
echo ""
63+
info "Ollama not found. Installing..."
64+
if [[ "$OS" == "mac" ]]; then
65+
if command -v brew &>/dev/null; then
66+
brew install ollama
67+
else
68+
fail "Please install Ollama from https://ollama.com/download
69+
(or install Homebrew first: https://brew.sh)"
70+
fi
71+
else
72+
# Official Linux install script
73+
curl -fsSL https://ollama.com/install.sh | sh
74+
fi
75+
fi
76+
ok "Ollama $(ollama --version 2>/dev/null | head -1)"
77+
78+
# ── 3. Install Python dependencies ───────────────────────────
79+
echo ""
80+
info "Installing Python packages..."
81+
"$PYTHON" -m pip install --quiet --upgrade pip
82+
"$PYTHON" -m pip install --quiet numpy pyzmq cryptography flask ollama
83+
84+
# Optional
85+
"$PYTHON" -m pip install --quiet pyyaml 2>/dev/null && ok "pyyaml" || warn "pyyaml unavailable (optional)"
86+
87+
# Playwright for browser control (optional)
88+
"$PYTHON" -m pip install --quiet playwright 2>/dev/null \
89+
&& playwright install chromium --with-deps 2>/dev/null \
90+
&& ok "playwright + chromium" \
91+
|| warn "playwright unavailable (optional — needed for browser tools)"
92+
93+
ok "Python packages ready"
94+
95+
# ── 4. Check Node.js ─────────────────────────────────────────
96+
echo ""
97+
if command -v node &>/dev/null; then
98+
ok "Node.js $(node --version)"
99+
if ! npm list -g @modelcontextprotocol/server-filesystem &>/dev/null; then
100+
info "Installing MCP filesystem server..."
101+
npm install -g @modelcontextprotocol/server-filesystem --silent \
102+
&& ok "MCP filesystem server installed" \
103+
|| warn "MCP filesystem server install failed (optional)"
104+
else
105+
ok "MCP filesystem server already installed"
106+
fi
107+
else
108+
warn "Node.js not found — MCP filesystem server unavailable.
109+
Andrew can still use [TOOL:read_file] without it.
110+
To install Node.js: https://nodejs.org or brew install node"
111+
fi
112+
113+
# ── 5. Create directories ─────────────────────────────────────
114+
mkdir -p knowledge_base logs agents plugins
115+
ok "Directories ready"
116+
117+
# ── 6. First boot ────────────────────────────────────────────
118+
echo ""
119+
if [[ ! -f "system_identity.json" ]]; then
120+
echo "============================================================"
121+
echo " FIRST BOOT — Identity setup required"
122+
echo "============================================================"
123+
"$PYTHON" master_init.py || fail "Setup failed. Check output above."
124+
else
125+
ok "Identity already configured"
126+
fi
127+
128+
# ── 7. Pull model ─────────────────────────────────────────────
129+
echo ""
130+
info "Checking for Qwen model..."
131+
if ! ollama list 2>/dev/null | grep -q "qwen"; then
132+
echo ""
133+
echo " Qwen 27B not found. Pulling now."
134+
echo " This is a large download — may take 10-30 minutes."
135+
echo ""
136+
if ! ollama pull qwen3:27b; then
137+
warn "qwen3:27b failed. Trying smaller fallback..."
138+
ollama pull qwen2.5:7b || warn "Model pull failed — set one up manually with: ollama pull <model>"
139+
fi
140+
else
141+
ok "Qwen model already downloaded"
142+
fi
143+
144+
# ── 8. Launch ────────────────────────────────────────────────
145+
# Ollama and the MCP filesystem server are now started by caios_bridge.py
146+
# itself (start_services()), so this works the same whether you launch via
147+
# this script or run `python3 caios_bridge.py` directly next time — see
148+
# SETUP.md. windows-mcp is skipped automatically on Mac/Linux since
149+
# start_services() only starts it when platform.system() == 'Windows'.
150+
echo ""
151+
echo "============================================================"
152+
echo " Setup complete. Launching CAIOS..."
153+
echo "============================================================"
154+
echo ""
155+
echo " Web UI: http://localhost:5000"
156+
echo " Press Ctrl+C to stop."
157+
echo ""
158+
159+
"$PYTHON" caios_bridge.py
160+

Project_Andrew/run_caios.bat

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,22 @@ if not exist "system_identity.json" (
101101

102102
:: ── 7. Pull model if not present ─────────────────────────────
103103
echo.
104-
echo [SETUP] Checking for Qwen 27B model...
105-
ollama list 2>nul | findstr "qwen" >nul
104+
echo [SETUP] Detecting GPU VRAM...
105+
for /f %%m in ('python detect_model.py 2^>nul') do set OLLAMA_MODEL=%%m
106+
107+
if not defined OLLAMA_MODEL (
108+
echo [WARN] VRAM detection failed. Defaulting to qwen2.5:7b
109+
echo Run 'ollama pull qwen3:27b' manually if you have a 24GB+ card.
110+
set OLLAMA_MODEL=qwen2.5:7b
111+
)
112+
echo [OK] Selected model: %OLLAMA_MODEL%
113+
114+
ollama list 2>nul | findstr "%OLLAMA_MODEL%" >nul
106115
if errorlevel 1 (
107-
echo.
108-
echo Qwen 27B not found. Pulling now — this is a large download.
109-
echo Progress will appear below. This may take 10-30 minutes
110-
echo depending on your connection.
111-
echo.
112-
ollama pull qwen3:27b
113-
if errorlevel 1 (
114-
echo.
115-
echo [WARN] qwen3:27b pull failed. Trying smaller fallback...
116-
ollama pull qwen2.5:7b
117-
)
116+
echo [SETUP] Pulling %OLLAMA_MODEL% — this may take 10-30 minutes.
117+
ollama pull %OLLAMA_MODEL%
118118
) else (
119-
echo [OK] Qwen model already downloaded
119+
echo [OK] %OLLAMA_MODEL% already downloaded
120120
)
121121

122122
:: ── 8. Launch ─────────────────────────────────────────────────

0 commit comments

Comments
 (0)