DTSO-Mtech_2025/WINDOWS_SETUP.md

12 KiB

🪟 Dynamic Traffic Signal Optimization - Windows Setup Guide

Complete Step-by-Step Installation and Setup Guide for Windows

This guide provides detailed instructions for setting up the Dynamic Traffic Signal Optimization project on Windows systems.


📋 Table of Contents

  1. Prerequisites
  2. System Requirements
  3. Step 1: Install Python
  4. Step 2: Install Git
  5. Step 3: Install SUMO Traffic Simulator
  6. Step 4: Clone and Setup Project
  7. Step 5: Create Virtual Environment
  8. Step 6: Install Dependencies
  9. Step 7: Configure Environment Variables
  10. Step 8: Verify Installation
  11. Step 9: Run the Project
  12. Troubleshooting
  13. GPU Setup (Optional)

🔧 Prerequisites

  • Windows 10 or Windows 11 (64-bit)
  • Administrator access to install software
  • At least 8GB RAM (16GB recommended)
  • 10GB free disk space
  • Internet connection for downloads

💻 System Requirements

Component Minimum Recommended
OS Windows 10 64-bit Windows 11 64-bit
RAM 8GB 16GB+
Storage 10GB free 20GB+ free
GPU Not required NVIDIA GPU (for acceleration)
Python 3.8+ 3.10+

🐍 Step 1: Install Python

  1. Download Python:

  2. Install Python:

    • Run the downloaded installer as Administrator
    • ⚠️ IMPORTANT: Check "Add Python to PATH" at the bottom
    • Click "Install Now"
    • Wait for installation to complete
    • Click "Close"
  3. Verify Installation:

    # Open Command Prompt (cmd) and run:
    python --version
    pip --version
    

Method 2: Microsoft Store (Alternative)

  1. Open Microsoft Store
  2. Search for "Python 3.11"
  3. Install the official Python version

🔧 Step 2: Install Git

  1. Download Git:

  2. Install Git:

    • Run the installer as Administrator
    • Use default settings (click "Next" through all options)
    • Complete the installation
  3. Verify Installation:

    git --version
    

🚦 Step 3: Install SUMO Traffic Simulator

Download and Install SUMO

  1. Download SUMO:

  2. Install SUMO:

    • Run the downloaded MSI file as Administrator
    • Follow the installation wizard
    • Choose installation directory (default: C:\Program Files (x86)\Eclipse\Sumo)
    • Complete the installation
  3. Add SUMO to PATH:

    • Right-click "This PC" → Properties
    • Click "Advanced system settings"
    • Click "Environment Variables"
    • Under "System Variables", find and select "Path"
    • Click "Edit" → "New"
    • Add: C:\Program Files (x86)\Eclipse\Sumo\bin
    • Click "OK" to close all dialogs
  4. Set SUMO_HOME Environment Variable:

    • In Environment Variables window (still open)
    • Under "System Variables", click "New"
    • Variable name: SUMO_HOME
    • Variable value: C:\Program Files (x86)\Eclipse\Sumo
    • Click "OK"
  5. Verify SUMO Installation:

    # Close and reopen Command Prompt, then run:
    sumo --version
    

📁 Step 4: Clone and Setup Project

  1. Create Project Directory:

    # Open Command Prompt and navigate to desired location
    cd C:\
    mkdir Projects
    cd Projects
    
  2. Clone Repository:

    git clone https://git.kronos-nexus.com/giteaAdmin/DTSO-Mtech_2025
    cd DTSO-Mtech_2025
    
  3. Create Directory Structure:

    # Create all necessary directories
    mkdir src\environment src\agents src\training src\evaluation src\utils
    mkdir config sumo_configs models\checkpoints
    mkdir data\raw data\processed logs\tensorboard
    mkdir results\plots results\analysis scripts notebooks tests
    

🐍 Step 5: Create Virtual Environment

  1. Create Virtual Environment:

    # In the project directory
    python -m venv venv
    
  2. Activate Virtual Environment:

    # Activate the environment (Windows Command Prompt)
    venv\Scripts\activate
    
    # For PowerShell users:
    venv\Scripts\Activate.ps1
    
  3. Verify Activation:

    • You should see (venv) at the beginning of your command prompt

📦 Step 6: Install Dependencies

  1. Create requirements.txt:

    # Create file with necessary dependencies
    echo torch>=1.9.0 > requirements.txt
    echo torchvision>=0.10.0 >> requirements.txt
    echo numpy>=1.21.0 >> requirements.txt
    echo pandas>=1.3.0 >> requirements.txt
    echo matplotlib>=3.4.0 >> requirements.txt
    echo seaborn>=0.11.0 >> requirements.txt
    echo opencv-python>=4.5.0 >> requirements.txt
    echo gym>=0.18.0 >> requirements.txt
    echo traci>=1.10.0 >> requirements.txt
    echo sumolib>=1.10.0 >> requirements.txt
    echo scikit-learn>=0.24.0 >> requirements.txt
    echo tensorboard>=2.6.0 >> requirements.txt
    echo tqdm>=4.62.0 >> requirements.txt
    echo PyYAML>=5.4.0 >> requirements.txt
    echo imageio>=2.9.0 >> requirements.txt
    echo pillow>=8.3.0 >> requirements.txt
    
  2. Install Dependencies:

    # Make sure virtual environment is activated
    pip install --upgrade pip
    pip install -r requirements.txt
    
  3. Wait for Installation:

    • This may take 10-15 minutes depending on your internet speed
    • PyTorch is a large package (~800MB)

🔧 Step 7: Configure Environment Variables

  1. Verify Environment Variables:

    echo %SUMO_HOME%
    echo %PATH%
    
  2. Test SUMO from Python:

    python -c "import traci; print('TraCI imported successfully')"
    python -c "import sumolib; print('SUMO library imported successfully')"
    

Step 8: Verify Installation

  1. Create and Run Setup Script:

    # Create setup verification script
    python scripts/setup_project.py
    
  2. Test Basic Functionality:

    # Test Python packages
    python -c "import torch; print('PyTorch version:', torch.__version__)"
    python -c "import numpy; print('NumPy version:', numpy.__version__)"
    python -c "import pandas; print('Pandas version:', pandas.__version__)"
    
  3. Test SUMO Integration:

    # Test SUMO command line
    sumo --help
    
    # Test SUMO with GUI (optional)
    sumo-gui
    

🚀 Step 9: Run the Project

9.1 Basic Training

# Make sure you're in the project directory with activated virtual environment
cd C:\Projects\DTSO-Mtech_2025
venv\Scripts\activate

# Run basic training
python main.py --mode train

9.2 Test Trained Model

# Test with pre-trained model
python main.py --mode test --model models/final_model.pth --episodes 5

9.3 Monitor Training Progress

# In a separate command prompt, start TensorBoard
venv\Scripts\activate
tensorboard --logdir logs/tensorboard

# Open browser and go to: http://localhost:6006

🔧 Troubleshooting

Common Issues and Solutions

1. Python not found

# Error: 'python' is not recognized
# Solution: Add Python to PATH or use:
py --version

2. SUMO not found

# Error: 'sumo' is not recognized
# Solution: Check PATH and SUMO_HOME environment variables
set PATH=%PATH%;C:\Program Files (x86)\Eclipse\Sumo\bin
set SUMO_HOME=C:\Program Files (x86)\Eclipse\Sumo

3. Permission Issues

# Run Command Prompt as Administrator
# Right-click Command Prompt → "Run as administrator"

4. Virtual Environment Issues

# If activation fails, try:
python -m venv --clear venv
venv\Scripts\activate

5. Package Installation Errors

# If pip install fails, try:
pip install --upgrade pip setuptools wheel
pip install --no-cache-dir -r requirements.txt

6. SUMO GUI Issues

# If SUMO GUI doesn't work, check if you have:
# - Visual C++ Redistributable installed
# - Updated graphics drivers

7. Memory Issues

# If training crashes due to memory:
# Edit config/config.yaml and reduce:
# - batch_size: 32 (instead of 64)
# - memory_size: 50000 (instead of 100000)

Windows-Specific Commands

# Check system information
systeminfo

# Check available disk space
dir C:\

# Check running processes
tasklist | findstr python

# Kill Python processes if needed
taskkill /f /im python.exe

🎮 GPU Setup (Optional)

NVIDIA GPU Setup

  1. Check GPU Compatibility:

    # Check if you have NVIDIA GPU
    nvidia-smi
    
  2. Install CUDA Toolkit:

    • Download from NVIDIA CUDA Toolkit
    • Install CUDA 11.8 or 12.x
    • Restart computer after installation
  3. Verify GPU Support:

    python -c "import torch; print('CUDA available:', torch.cuda.is_available())"
    python -c "import torch; print('GPU count:', torch.cuda.device_count())"
    
  4. Run with GPU:

    python main.py --mode train --gpu
    

📊 Performance Monitoring

System Monitoring During Training

  1. Task Manager:

    • Press Ctrl + Shift + Esc
    • Monitor CPU, RAM, and GPU usage
  2. Command Line Monitoring:

    # Monitor GPU usage (if NVIDIA)
    nvidia-smi -l 5
    
    # Monitor system resources
    wmic cpu get loadpercentage /value
    

🔄 Project Management

Regular Maintenance

# Update packages
pip list --outdated
pip install --upgrade package_name

# Clean cache
pip cache purge

# Backup important files
xcopy models\ backup\models\ /E /I
xcopy results\ backup\results\ /E /I

Development Workflow

# Daily development routine
cd C:\Projects\DTSO-Mtech_2025
venv\Scripts\activate
git pull origin main
python main.py --mode train

📝 Notes for Windows Users

  1. File Paths: Use backslashes (\) or forward slashes (/) in paths
  2. Command Prompt vs PowerShell: Both work, but commands may differ slightly
  3. Antivirus: Add project folder to antivirus exclusions for better performance
  4. Windows Defender: May slow down file operations; consider temporary exclusion
  5. Updates: Keep Windows, Python, and SUMO updated for best performance

📞 Support and Resources

Getting Help


Final Checklist

Before starting development, ensure:

  • Python 3.8+ installed and in PATH
  • Git installed and configured
  • SUMO installed with GUI working
  • Environment variables set (SUMO_HOME, PATH)
  • Virtual environment created and activated
  • All dependencies installed successfully
  • Basic functionality tests passing
  • Project structure created
  • Configuration files in place

🎉 Congratulations! Your Windows development environment is ready!

You can now proceed with training your traffic signal optimization model. Start with:

python main.py --mode train --episodes 100

For any issues, refer to the troubleshooting section or check the main README.md file.