Skip to main content

Installation

Requirements

  • Python 3.12+
  • PyTorch 2.0+
  • CUDA 11.8+ (for GPU acceleration)

Quick Install

uv is an extremely fast Python package and project manager, written in Rust. It is the recommended way to manage this project.

# Clone the repository
git clone https://github.com/phborba/pytorch_segmentation_models_trainer.git
cd pytorch_segmentation_models_trainer

# Install dependencies and create a virtual environment
uv sync

Option 2: PyPI

pip install pytorch_segmentation_models_trainer

Option 3: From Source (pip)

git clone https://github.com/phborba/pytorch_segmentation_models_trainer.git
cd pytorch_segmentation_models_trainer
pip install -e .

Verify Installation

Test your installation:

import pytorch_segmentation_models_trainer
print("Installation successful!")

# Check available modes
from pytorch_segmentation_models_trainer.main import main

Or use the CLI:

pytorch-smt --help

Optional Dependencies

For Advanced Features

# For visualization and plotting
pip install matplotlib seaborn

# For additional image processing
pip install opencv-python-headless

# For COCO dataset support
pip install pycocotools

# For PostGIS database integration
pip install psycopg2-binary geopandas

# For advanced metrics
pip install scikit-learn

Development Dependencies

pip install pytest black flake8 pre-commit

Common Issues

CUDA/GPU Issues

Problem: CUDA out of memory

RuntimeError: CUDA out of memory

Solution: Reduce batch size in your config:

hyperparameters:
batch_size: 1 # Reduce from higher value

Problem: No CUDA devices available

AssertionError: Torch not compiled with CUDA support

Solution: Install PyTorch with CUDA:

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

Import Errors

Problem: ModuleNotFoundError: No module named 'pytorch_scatter'

Solution: Install pytorch-scatter for your CUDA version:

pip install torch-scatter -f https://data.pyg.org/whl/torch-2.0.0+cu118.html

Problem: ImportError: cannot import name 'instantiate'

Solution: Update Hydra:

pip install --upgrade hydra-core

Tips

  1. Use uv (Highly Recommended):

    uv sync
    source .venv/bin/activate
  2. Check your CUDA version:

    nvidia-smi
  3. For M1/M2 Macs: Install with MPS support:

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

Next Steps