# Dual-GPU Setup: GTX 1660 (CUDA) + RX 6800 (ROCm)

## Architecture

```
┌─────────────────────────────────────────────────────────┐
│  HTTP Request → FastAPI Main Process                    │
└────────────────┬────────────────────────────────────────┘
                 │
                 ▼
┌─────────────────────────────────────────────────────────┐
│  Process 1: Soprano Generator (GTX 1660 CUDA)          │
│  - Runs in CUDA venv                                    │
│  - Soprano TTS: text → audio (32kHz)                    │
│  - Outputs to Redis/ZMQ queue                           │
│  Device: cuda:0 (GTX 1660)                              │
└────────────────┬────────────────────────────────────────┘
                 │ Audio chunks (numpy arrays)
                 ▼
┌─────────────────────────────────────────────────────────┐
│  Process 2: RVC Processor (RX 6800 ROCm)               │
│  - Runs in ROCm venv                                    │
│  - RVC: 32kHz → 48kHz converted audio                   │
│  - Outputs to client HTTP streams                       │
│  Device: cuda:0 (RX 6800, but seen as cuda:0)          │
└─────────────────────────────────────────────────────────┘
```

## Virtual Environment Setup

### 1. CUDA venv for Soprano (GTX 1660)
```bash
cd /home/koko210Serve/docker/miku-discord/soprano_to_rvc
python -m venv .venv-cuda
source .venv-cuda/bin/activate

# Install CUDA PyTorch
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121

# Install Soprano dependencies
pip install -r soprano/requirements.txt
pip install lmdeploy  # or skip if using transformers backend only
pip install redis zmq  # for IPC
```

### 2. ROCm venv for RVC (RX 6800) - Already exists
```bash
# Current .venv has ROCm PyTorch
source .venv/bin/activate
pip install redis zmq  # add IPC libraries
```

## Implementation Files

### soprano_server.py (Process 1 - CUDA)
Runs Soprano TTS on GTX 1660, outputs to Redis queue.

### rvc_server.py (Process 2 - ROCm)  
Runs RVC on RX 6800, reads from Redis queue, serves HTTP.

### coordinator.py
Manages both processes, handles restarts.

## Benefits

1. **No GPU contention** - Each model has dedicated GPU
2. **No kernel warmup issues** - GTX 1660 has mature CUDA with pre-compiled kernels
3. **Better utilization** - Both GPUs work in parallel
4. **Faster overall** - No waiting for shared GPU resources

## Expected Performance

- **Soprano on GTX 1660**: ~1.5x realtime (similar to RX 6800 isolated)
- **RVC on RX 6800**: ~1.56x realtime (isolated, no contention)
- **Total pipeline**: ~1.5x realtime (limited by slower component)
- **No warmup needed**: CUDA kernels pre-compiled

## Testing Approach

1. Test Soprano alone on GTX 1660
2. Test RVC alone on RX 6800  
3. Test full pipeline with Redis communication
4. Verify no GPU contention with monitoring

## Fallback

If GTX 1660 is too slow for Soprano, reverse the assignment:
- Soprano on RX 6800 (faster GPU)
- RVC on GTX 1660 (simpler model)
