File size: 11,266 Bytes
b6ae7b8 | 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 | # Stack 2.9 - Detailed Setup Guide
This guide provides comprehensive instructions for setting up Stack 2.9 in various environments.
## Table of Contents
- [Prerequisites](#prerequisites)
- [Hardware Requirements](#hardware-requirements)
- [Software Prerequisites](#software-prerequisites)
- [Installation Methods](#installation-methods)
- [Configuration](#configuration)
- [Docker Setup](#docker-setup)
- [Development Setup](#development-setup)
- [Troubleshooting](#troubleshooting)
---
## Prerequisites
### Minimum Requirements
| Component | Minimum | Recommended |
|-----------|---------|-------------|
| **Python** | 3.8+ | 3.11+ |
| **Node.js** | 18+ | 20 LTS |
| **RAM** | 8 GB | 16 GB |
| **GPU VRAM** | 8 GB | 24 GB |
| **Disk Space** | 10 GB | 50 GB |
### Operating Systems
- ✅ **Linux** (Ubuntu 20.04+, CentOS 8+, Debian 11+)
- ✅ **macOS** (12 Monterey or later)
- ⚠️ **Windows** (via WSL2 or Docker)
---
## Hardware Requirements
### CPU-Only Inference (Testing/Development)
For local development and testing without GPU:
| Component | Specification |
|-----------|---------------|
| **CPU** | 4+ cores |
| **RAM** | 8 GB minimum |
| **Storage** | 10 GB free space |
### GPU Inference (Production)
For production deployment with optimal performance:
| Component | Specification | Notes |
|-----------|---------------|-------|
| **GPU** | NVIDIA GPU with 24GB+ VRAM | A100, H100, RTX 3090, RTX 4090 |
| **CPU** | 8+ cores | AMD Ryzen 9, Intel i9 |
| **RAM** | 32 GB | 64 GB recommended |
| **NVMe Storage** | 50 GB+ | For model caching |
### Multi-GPU Setup
For high-throughput production workloads:
```bash
# Example: 2x A100 80GB setup
export CUDA_VISIBLE_DEVICES=0,1
# Stack 2.9 will automatically use tensor parallelism
python stack.py --num-gpus 2
```
---
## Software Prerequisites
### 1. Python Installation
**Linux/macOS:**
```bash
# Using pyenv (recommended)
curl https://pyenv.run | bash
pyenv install 3.11.4
pyenv global 3.11.4
# Verify installation
python --version
```
**Windows (WSL2):**
```bash
# Install WSL2 first
wsl --install -d Ubuntu-22.04
# Then install Python
sudo apt update
sudo apt install python3.11 python3.11-venv python3-pip
```
### 2. Node.js Installation
**Linux/macOS:**
```bash
# Using nvm (recommended)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install 20
nvm use 20
# Verify installation
node --version
```
**Windows:**
Download from [nodejs.org](https://nodejs.org/) or use winget:
```powershell
winget install OpenJS.NodeJS.LTS
```
### 3. CUDA Setup (GPU Support)
```bash
# Check CUDA version
nvidia-smi
# Install CUDA Toolkit (if needed)
# Download from: https://developer.nvidia.com/cuda-downloads
# Install cuDNN
sudo apt install libcudnn8 libcudnn8-dev
# Verify CUDA
python -c "import torch; print(torch.cuda.is_available())"
```
### 4. Docker Installation (Optional)
```bash
# Linux
curl -fsSL https://get.docker.com | bash
sudo usermod -aG docker $USER
# macOS
brew install --cask docker
# Windows
# Download Docker Desktop from https://docker.com
```
---
## Installation Methods
### Method 1: Standard Installation
```bash
# Clone repository
git clone https://github.com/openclaw/stack-2.9.git
cd stack-2.9
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Linux/macOS
# or: .venv\Scripts\activate # Windows
# Install Python dependencies
pip install -r requirements.txt
# Install Node.js dependencies (for voice features)
npm install
# Verify installation
python stack.py --version
```
### Method 2: Development Installation
```bash
# Clone and setup
git clone https://github.com/openclaw/stack-2.9.git
cd stack-2.9
# Install in editable mode with dev dependencies
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
# Run tests to verify
pytest
```
### Method 3: Docker Installation
```bash
# Build the image
docker build -t stack-2.9 .
# Run with GPU support (Linux)
docker run --gpus all -p 3000:3000 \
-v $(pwd)/data:/app/data \
stack-2.9
# Run on macOS (uses Metal acceleration)
docker run -p 3000:3000 \
-v $(pwd)/data:/app/data \
stack-2.9
```
### Method 4: Kubernetes Deployment
```yaml
# stack-2.9-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: stack-2-9
spec:
replicas: 2
selector:
matchLabels:
app: stack-2-9
template:
metadata:
labels:
app: stack-2-9
spec:
containers:
- name: stack-2-9
image: stack-2.9:latest
resources:
limits:
nvidia.com/gpu: 1
memory: 32Gi
ports:
- containerPort: 3000
env:
- name: API_KEY
valueFrom:
secretKeyRef:
name: stack-2-9-secrets
key: api-key
```
---
## Configuration
### Environment Variables
Create a `.env` file in the project root:
```bash
# API Configuration
API_HOST=0.0.0.0
API_PORT=3000
API_KEY=your-secret-api-key-here
# Model Configuration
MODEL_NAME=qwen/qwen2.5-coder-32b
CONTEXT_WINDOW=131072
QUANTIZATION=awq
# GPU Configuration
CUDA_VISIBLE_DEVICES=0
NUM_GPUS=1
# Self-Evolution
ENABLE_SELF_EVOLUTION=true
EVOLUTION_INTERVAL_HOURS=24
# Logging
LOG_LEVEL=INFO
LOG_FILE=stack-2.9.log
# Database
MEMORY_DB_PATH=./self_evolution/data/memory.db
```
### Configuration File
Create `config.yaml` for advanced configuration:
```yaml
# Stack 2.9 Configuration
server:
host: 0.0.0.0
port: 3000
workers: 4
timeout: 300
model:
name: qwen/qwen2.5-coder-32b
device: cuda
quantization: awq
context_window: 131072
temperature: 0.7
max_tokens: 4096
tools:
enabled:
- file_operations
- git_operations
- shell_commands
- api_calls
- search
- voice
sandbox:
enabled: true
timeout: 30
self_evolution:
enabled: true
interval_hours: 24
min_success_for_pattern: 3
min_failure_for_pattern: 2
max_memories: 10000
memory:
db_path: ./self_evolution/data/memory.db
embedding_dim: 128
similarity_threshold: 0.3
rate_limiting:
enabled: true
requests_per_minute: 100
tokens_per_day: 100000
concurrent_requests: 5
logging:
level: INFO
file: stack-2.9.log
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
```
### API Configuration
#### Authentication
```bash
# Generate API key
openssl rand -hex 32
# Set in environment
export API_KEY=your-generated-key
```
#### Rate Limiting
| Tier | Requests/min | Tokens/day | Concurrent |
|------|-------------|------------|------------|
| Free | 100 | 100,000 | 5 |
| Pro | 1,000 | 10,000,000 | 20 |
| Enterprise | Custom | Custom | Custom |
---
## Docker Setup
### Building the Image
```bash
# Build with GPU support
docker build -t stack-2.9:gpu -f Dockerfile.gpu .
# Build for CPU only
docker build -t stack-2.9:cpu -f Dockerfile.cpu .
```
### Running with Docker Compose
```yaml
# docker-compose.yml
version: '3.8'
services:
stack-2-9:
build: .
ports:
- "3000:3000"
environment:
- API_KEY=${API_KEY}
- MODEL_NAME=qwen/qwen2.5-coder-32b
volumes:
- ./data:/app/data
- ./config.yaml:/app/config.yaml
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
redis:
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
- redis_data:/data
volumes:
redis_data:
```
```bash
# Start services
docker-compose up -d
# View logs
docker-compose logs -f stack-2-9
```
---
## Development Setup
### Setting Up Development Environment
```bash
# Clone repository
git clone https://github.com/openclaw/stack-2.9.git
cd stack-2.9
# Create virtual environment
python -m venv .venv
source .venv/bin/activate
# Install with dev dependencies
pip install -e ".[dev]"
# Install pre-commit
pre-commit install
# Run pre-commit checks
pre-commit run --all-files
# Run tests
pytest -v
```
### IDE Setup
**VS Code:**
```json
// .vscode/settings.json
{
"python.defaultInterpreterPath": ".venv/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.provider": "black",
"editor.formatOnSave": true,
"files.exclude": {
"**/__pycache__": true,
"**/*.pyc": true
}
}
```
**PyCharm:**
1. Open Settings → Project → Python Interpreter
2. Add Interpreter → Existing Environment
3. Select `.venv/bin/python`
4. Enable Black for formatting
### Running Development Server
```bash
# Start with auto-reload
python -m stack_cli.dev
# Or with debug mode
DEBUG=1 python stack.py
```
---
## Troubleshooting
### Common Issues
#### 1. Import Errors
**Problem:** `ModuleNotFoundError: No module named 'stack_cli'`
**Solution:**
```bash
# Reinstall in editable mode
pip install -e .
# Or add to PYTHONPATH
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
```
#### 2. CUDA/GPU Issues
**Problem:** `CUDA out of memory` or `RuntimeError: CUDA not available`
**Solutions:**
```bash
# Check GPU availability
python -c "import torch; print(torch.cuda.is_available())"
# Clear GPU cache
nvidia-smi --gpu-reset
# Use smaller batch size
python stack.py --batch-size 1
# Use quantization
python stack.py --quantization awq
```
#### 3. Memory Issues
**Problem:** `OutOfMemoryError` during inference
**Solutions:**
```bash
# Increase swap space (Linux)
sudo fallocate -l 16G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
# Use model quantization
python stack.py --quantization 4bit
# Reduce context window
python stack.py --context-window 32768
```
#### 4. Permission Issues (Linux)
**Problem:** `Permission denied` errors
**Solutions:**
```bash
# Fix script permissions
chmod +x stack.py install.sh setup.sh
# Fix directory permissions
chmod 755 self_evolution/data
# Add user to docker group
sudo usermod -aG docker $USER
newgrp docker
```
#### 5. Node.js Issues
**Problem:** `npm ERR!` during installation
**Solutions:**
```bash
# Clear npm cache
npm cache clean --force
# Install with legacy peer deps
npm install --legacy-peer-deps
# Use specific Node version
nvm use 20
```
#### 6. Port Already in Use
**Problem:** `OSError: [Errno 98] Address already in use`
**Solutions:**
```bash
# Find process using port 3000
lsof -i :3000
# Kill the process
kill -9 <PID>
# Or use a different port
python stack.py --port 3001
```
### Diagnostic Commands
```bash
# Check system resources
nvidia-smi
free -h
df -h
# Check Python environment
python --version
pip list | grep -E "(torch|transformers|openai)"
# Verify installation
python -c "from stack_cli import cli; print('OK')"
# Run diagnostics
python scripts/diagnostics.py
```
### Getting Help
If you encounter issues not covered here:
1. **Check existing issues:** [GitHub Issues](https://github.com/openclaw/stack-2.9/issues)
2. **Ask in discussions:** [GitHub Discussions](https://github.com/openclaw/stack-2.9/discussions)
3. **Email support:** support@stack2.9.openclaw.org
---
## Next Steps
- [API Documentation](API.md) - Integrate Stack 2.9 into your applications
- [Architecture Guide](ARCHITECTURE.md) - Understand the technical internals
- [Contributing Guide](CONTRIBUTING.md) - Help improve Stack 2.9
|