try fixing GPU (torch)

This commit is contained in:
Dobromir Popov
2025-11-17 13:06:37 +02:00
parent 4fcadcdbff
commit 43a7d75daf
9 changed files with 1393 additions and 11 deletions

103
readme.md
View File

@@ -22,20 +22,56 @@ A modular, scalable cryptocurrency trading system with CNN and RL components for
## Features
- **Cross-Platform GPU Support**: Same code works with NVIDIA (CUDA), AMD (ROCm), and CPU
- **Multi-timeframe Analysis**: 1s, 1m, 5m, 1h, 4h, 1d scalping focus
- **CNN Pattern Recognition**: Real market pattern detection with temporal attention
- **RL Trading Agent**: Reinforcement learning with real historical backtesting
- **Real-time Data**: Live market data from Binance API
- **Web Dashboard**: Real-time monitoring and visualization
- **Modular Architecture**: Clean separation of concerns
- **Auto GPU Detection**: Setup script automatically installs correct PyTorch for your hardware
## Quick Start
### 1. Install Dependencies
**Automatic Setup (Recommended)**
```bash
# Clone and setup virtual environment
git clone <repo-url> gogo2
cd gogo2
python -m venv venv
source venv/bin/activate # Linux/Mac
# .\\venv\\Scripts\\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Auto-detect GPU and install correct PyTorch
./scripts/setup-pytorch.sh
```
The setup script automatically detects your hardware and installs the right PyTorch build:
-**NVIDIA GPU** → CUDA PyTorch
-**AMD GPU** → ROCm PyTorch
-**No GPU** → CPU PyTorch
**Manual PyTorch Install** (if needed)
```bash
# CPU-only (development without GPU)
pip install torch --index-url https://download.pytorch.org/whl/cpu
# NVIDIA GPU (CUDA 12.1)
pip install torch --index-url https://download.pytorch.org/whl/cu121
# AMD GPU (ROCm 6.2)
pip install torch --index-url https://download.pytorch.org/whl/rocm6.2
```
💡 **Cross-Platform**: The same codebase works with NVIDIA (CUDA), AMD (ROCm), and CPU! See [CROSS_PLATFORM_GPU.md](CROSS_PLATFORM_GPU.md) for details.
### 2. Configure Settings
Edit `config.yaml` to set your preferences:
```yaml
@@ -72,6 +108,58 @@ python training_runner.py --mode realtime --duration 4
python training_runner.py --mode backtest --start-date 2024-01-01 --end-date 2024-12-31
```
## GPU Support
### ✅ Same Codebase Works Everywhere!
This project supports **NVIDIA (CUDA)**, **AMD (ROCm)**, and **CPU** with the **same code**. PyTorch abstracts the hardware differences - just install the right PyTorch build for your hardware.
### Verified Hardware
**NVIDIA GPUs:**
- RTX 40 Series (4090, 4080, 4070, etc.) - 10-15x faster training
- RTX 30 Series (3090, 3080, 3070, etc.) - 8-12x faster training
- RTX 20 Series (2080 Ti, 2070, etc.) - 6-10x faster training
**AMD GPUs:**
- Strix Halo (Radeon 8050S/8060S - RDNA 3.5) - 2-3x faster training
- RDNA 3 (RX 7900 XTX, 7800 XT, etc.) - 6-10x faster training
- RDNA 2 (RX 6900 XT, 6800 XT, etc.) - 5-8x faster training
**CPU:**
- Any x86_64 (baseline performance)
### Verify Your Setup
```bash
python -c "
import torch
print(f'PyTorch: {torch.__version__}')
print(f'GPU available: {torch.cuda.is_available()}')
if torch.cuda.is_available():
print(f'Device: {torch.cuda.get_device_name(0)}')
print(f'Memory: {torch.cuda.get_device_properties(0).total_memory / 1024**3:.1f} GB')
"
```
### Alternative: Using Existing ROCm Docker Containers
If you already have ROCm Docker containers running, you can use them for development:
```bash
# Attach to an existing ROCm container
./scripts/attach-to-rocm-container.sh
# See documentation for details
# docs/USING_EXISTING_ROCM_CONTAINER.md
```
### Documentation
📖 **Cross-Platform Guide**: [CROSS_PLATFORM_GPU.md](CROSS_PLATFORM_GPU.md)
📖 **Quick Start**: [QUICK_START.md](QUICK_START.md)
📖 **Docker Setup**: [docs/USING_EXISTING_ROCM_CONTAINER.md](docs/USING_EXISTING_ROCM_CONTAINER.md)
## Architecture
```
@@ -153,10 +241,23 @@ Access TensorBoard at: http://localhost:6006
## Performance
### Training Speed Comparison
| Hardware | Relative Speed | Notes |
|----------|----------------|-------|
| **NVIDIA RTX 4090** | 10-15x | Best performance |
| **NVIDIA RTX 3090** | 8-12x | Excellent |
| **AMD RX 7900 XTX** | 6-10x | Very good |
| **AMD Strix Halo (iGPU)** | 2-3x | Good for laptop |
| **CPU (12+ cores)** | 1.0x | Baseline |
### System Resources
- **Memory Usage**: <2GB per model
- **Training Speed**: ~20 seconds for 50 epochs
- **Training Speed**: ~20 seconds for 50 epochs (GPU)
- **Real Data Processing**: 1000+ candles per timeframe
- **Feature Count**: Dynamically detected from real data (typically 48)
- **Inference**: Real-time capable on all GPUs
## Monitoring