Skip to content

Latest commit

 

History

History
288 lines (212 loc) · 5.22 KB

File metadata and controls

288 lines (212 loc) · 5.22 KB

Installation Guide

Prerequisites

  • Python 3.8 or higher
  • pip package manager
  • Virtual environment (recommended)

Step-by-Step Installation

1. Create Virtual Environment (Recommended)

# Create virtual environment
python -m venv venv

# Activate virtual environment
# On Linux/Mac:
source venv/bin/activate
# On Windows:
venv\Scripts\activate

2. Install Dependencies

# Navigate to project directory
cd Hackathon_1_final

# Install required packages
pip install -r requirements.txt

3. Install Package (Optional)

For development/editable installation:

pip install -e .

For standard installation:

pip install .

After installation, you can use the CLI command:

edge-compress --model model.pt --output compressed

Dependency Details

Core Dependencies (Required)

  • numpy - Numerical operations
  • torch - PyTorch deep learning framework
  • tensorflow - TensorFlow deep learning framework
  • onnx - ONNX model format
  • onnxruntime - ONNX inference runtime

Optimization Dependencies (Required)

  • tensorflow-model-optimization - TensorFlow compression tools
  • torch-pruning - PyTorch pruning utilities

Conversion Dependencies (Required)

  • tf2onnx - TensorFlow to ONNX conversion

Optional Dependencies

For Hugging Face model support:

pip install transformers accelerate

For vision model support:

pip install timm

For ONNX optimization:

pip install onnx-simplifier

For development:

pip install pytest black flake8

Verify Installation

Quick Test

python test_framework.py

This will run a series of tests to verify:

  • All modules can be imported
  • Engine can be initialized
  • Configuration can be loaded
  • Model analysis works
  • Pipeline planning works

Manual Verification

# Test import
from edge_compressor import CompressionEngine

# Initialize engine
engine = CompressionEngine()
print("✓ Installation successful!")

Troubleshooting

Issue: "No module named 'torch'"

Solution:

pip install torch torchvision torchaudio

For CPU-only PyTorch (smaller, faster install):

pip install torch --index-url https://download.pytorch.org/whl/cpu

Issue: "No module named 'tensorflow'"

Solution:

pip install tensorflow

For CPU-only TensorFlow:

pip install tensorflow-cpu

Issue: "No module named 'edge_compressor'"

Solution: Make sure you're in the project directory:

cd Hackathon_1_final
export PYTHONPATH="${PYTHONPATH}:$(pwd)"

Or install the package:

pip install -e .

Issue: Version conflicts

Solution: Create a fresh virtual environment:

# Deactivate current environment
deactivate

# Remove old environment
rm -rf venv

# Create new environment
python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows

# Install dependencies
pip install -r requirements.txt

Issue: ONNX Runtime errors

Solution: Install specific ONNX Runtime version:

pip install onnxruntime==1.12.0

For GPU support:

pip install onnxruntime-gpu

Platform-Specific Notes

Linux

All dependencies should install without issues. Make sure you have:

sudo apt-get update
sudo apt-get install python3-dev python3-pip

macOS

For M1/M2 Macs, use:

# Install TensorFlow for Apple Silicon
pip install tensorflow-macos tensorflow-metal

# Install PyTorch for Apple Silicon
pip install torch torchvision torchaudio

Windows

Make sure you have Visual C++ redistributables installed for ONNX Runtime:

System Requirements

Minimum Requirements

  • Python 3.8+
  • 4GB RAM
  • 2GB free disk space

Recommended Requirements

  • Python 3.9+
  • 8GB+ RAM
  • 5GB+ free disk space
  • GPU (optional, for faster compression)

GPU Support (Optional)

CUDA (NVIDIA GPUs)

For PyTorch with CUDA:

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

For TensorFlow with CUDA:

pip install tensorflow[and-cuda]

Verify GPU Support

# PyTorch
import torch
print(f"CUDA available: {torch.cuda.is_available()}")

# TensorFlow
import tensorflow as tf
print(f"GPU devices: {tf.config.list_physical_devices('GPU')}")

Docker Installation (Alternative)

Create a Dockerfile:

FROM python:3.9

WORKDIR /app

COPY requirements.txt .
RUN pip install -r requirements.txt

COPY edge_compressor ./edge_compressor
COPY *.py ./

CMD ["python", "test_framework.py"]

Build and run:

docker build -t edge-compressor .
docker run -v $(pwd)/models:/app/models edge-compressor

Next Steps

After successful installation:

  1. Run tests: python test_framework.py
  2. Try examples: python example_usage.py
  3. Read quick start: See QUICKSTART.md
  4. Explore CLI: python -m edge_compressor.cli --help

Support

If you encounter issues not covered here:

  1. Check Python version: python --version
  2. Check pip version: pip --version
  3. List installed packages: pip list
  4. Check for conflicts: pip check

Installation complete? Let's compress some models! 🚀