This guide provides detailed instructions for installing FedLearn and its dependencies.
- Python: 3.10 or higher
- RAM: 8GB (16GB+ recommended for LLM training)
- Storage: 5GB free space
- OS: Linux, macOS, or Windows
- GPU: CUDA-capable GPU (NVIDIA)
- CUDA: 12.1 or higher
- RAM: 16GB+
- Storage: 20GB+ for model checkpoints
# Clone the repository
git clone https://github.com/Learning-Optimization-Group/FedLearn-Platform.git
cd FedLearn-Platform/framework
# Install PyTorch with CUDA support (if you have GPU)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
# Install FedLearn and dependencies
pip install -e .# Clone repository
git clone https://github.com/Learning-Optimization-Group/FedLearn-Platform.git
cd FedLearn-Platform/framework
# Install PyTorch (CPU version)
pip install torch torchvision torchaudio
# Install FedLearn
pip install -e .For contributors who want to modify the framework:
# Clone repository
git clone https://github.com/Learning-Optimization-Group/FedLearn-Platform.git
cd FedLearn-Platform/framework
# Install PyTorch with CUDA
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
# Install in editable mode with dev dependencies
pip install -e ".[dev]"
# Verify installation
pytest tests/After installation, verify everything works:
import fedlearn as fl
import torch
print(f"FedLearn imported successfully")
print(f"PyTorch version: {torch.__version__}")
print(f"CUDA available: {torch.cuda.is_available()}")
if torch.cuda.is_available():
print(f"CUDA version: {torch.version.cuda}")
print(f"GPU: {torch.cuda.get_device_name(0)}")Expected output:
FedLearn imported successfully
PyTorch version: 2.7.0+cu121
CUDA available: True
CUDA version: 12.1
GPU: NVIDIA GeForce RTX 3090
# GPU version (CUDA 12.1)
pip install torch==2.7.0 torchvision==0.21.0 torchaudio==2.7.0 --index-url https://download.pytorch.org/whl/cu121
# CPU version
pip install torch==2.7.0 torchvision==0.21.0 torchaudio==2.7.0pip install flwr==1.20.0 flwr-datasets==0.5.0pip install transformers>=4.57.0 datasets>=3.1.0 tokenizers>=0.21.4pip install grpcio>=1.75.1 grpcio-tools>=1.75.1 protobuf>=4.21.6Solution:
# Verify CUDA toolkit installation
nvcc --version
# Reinstall PyTorch with correct CUDA version
pip uninstall torch torchvision torchaudio
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121Solution:
# Update pip and setuptools
pip install --upgrade pip setuptools wheel
# Install gRPC with pre-built wheels
pip install --upgrade grpcio grpcio-toolsSolution:
- Reduce batch size in config file
- Enable gradient checkpointing
- Use mixed precision training (enabled by default)
- Consider using gradient accumulation
Solution:
# Ensure you're in the framework directory
cd FedLearn-Platform/framework
# Reinstall in editable mode
pip install -e .
# Verify package location
pip show fedlearnSolution:
# Find process using port 50051
lsof -i :50051
# Kill the process (replace PID)
kill -9 <PID>
# Or use a different port
python run_server.py --port 50052Using a virtual environment isolates dependencies:
# Create virtual environment
python -m venv fedlearn-env
# Activate
source fedlearn-env/bin/activate # Linux/Mac
fedlearn-env\Scripts\activate # Windows
# Install FedLearn
cd FedLearn-Platform/framework
pip install -e .# Create conda environment
conda create -n fedlearn python=3.10
# Activate
conda activate fedlearn
# Install PyTorch
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
# Install FedLearn
cd FedLearn-Platform/framework
pip install -e .For containerized deployment:
# Build Docker image (from repository root)
docker build -t fedlearn:latest -f docker/Dockerfile .
# Run container
docker run -it --gpus all fedlearn:latest bash- No special requirements
- GPU support works out of the box with CUDA drivers
- Apple Silicon (M1/M2): Use MPS backend for GPU acceleration
- Intel Macs: CPU-only installation recommended
# Check MPS availability (Apple Silicon)
import torch
print(f"MPS available: {torch.backends.mps.is_available()}")- Use PowerShell or Command Prompt
- Ensure Microsoft Visual C++ Redistributable is installed
- GPU support requires NVIDIA drivers and CUDA toolkit
After successful installation:
- Quick Start: Run the Quick Start Guide
- Examples: Try the Simple Federation Example
- Documentation: Explore the API Reference
- PyTorch Installation: https://pytorch.org/get-started/locally/
- CUDA Toolkit: https://developer.nvidia.com/cuda-downloads
- gRPC Documentation: https://grpc.io/docs/languages/python/quickstart/
If you encounter issues not covered here:
- Check GitHub Issues
- Create a new issue with detailed error messages
- Include Python version, OS, and CUDA version (if applicable)