Installation¶
Requirements¶
- Python: 3.8 or higher
- PyTorch: 1.0 or higher
- NumPy: For numerical operations
- SciPy: For statistical functions
- scikit-learn: For K-means initialization and metrics
Installation Methods¶
From PyPI (Recommended)¶
The easiest way to install tgmm is using pip:
This will install the latest stable release along with all required dependencies.
From Source (Development)¶
For the latest features or if you want to contribute:
# Clone the repository
git clone https://github.com/adriansousapoza/TorchGMM.git
cd TorchGMM
# Install in editable mode
pip install -e .
The -e flag installs in editable mode, so changes to the source code are immediately available.
With GPU Support¶
tgmm automatically uses CUDA if available. To enable GPU acceleration:
-
Install CUDA-enabled PyTorch following the official PyTorch installation guide
-
Verify CUDA availability:
-
Use GPU in tgmm:
Optional Dependencies¶
For running tutorials and visualization:
For building documentation:
Verification¶
Verify your installation:
import tgmm
print(f"tgmm version: {tgmm.__version__}")
# Test basic functionality
from tgmm import GaussianMixture
import torch
X = torch.randn(100, 2)
gmm = GaussianMixture(n_components=3, n_features=2)
gmm.fit(X)
labels = gmm.predict(X)
print(f"Fitted GMM with {gmm.n_components} components")
print(f"Converged: {gmm.converged_}")
Troubleshooting¶
Import Errors¶
If you encounter import errors:
# Ensure all dependencies are installed
pip install torch numpy scipy scikit-learn
# Reinstall tgmm
pip uninstall tgmm
pip install tgmm
CUDA Errors¶
If you have CUDA-related issues:
-
Check PyTorch CUDA installation:
-
Fall back to CPU:
Version Conflicts¶
If you have version conflicts with dependencies:
# Create a fresh virtual environment
python -m venv tgmm_env
source tgmm_env/bin/activate # On Windows: tgmm_env\Scripts\activate
# Install tgmm
pip install tgmm
Next Steps¶
Next steps: Check out the Quick Start Guide or explore the Tutorials. - API Reference - Complete API documentation