System Requirements
Python Version
Python 3.8 or higherResults were computed using Python 3.8
GPU Memory
11GB VRAM minimumRequired for most experiments at standard image sizes
Operating System
Linux (recommended)Also works on macOS and Windows with WSL2
CUDA Support
CUDA 10.2 or higherOptional but strongly recommended for GPU acceleration
Installation Steps
Install Core Dependencies
Install all required packages from This installs:
requirements.txt:Core Dependencies
Core Dependencies
- click >= 8.0.3: Command-line interface framework
- torch >= 1.10.0: PyTorch deep learning framework
- torchvision >= 0.11.1: Pre-trained models and image transforms
- pretrainedmodels >= 0.7.4: Additional backbone architectures
Scientific Computing
Scientific Computing
- scikit-image >= 0.18.3: Image processing
- scikit-learn >= 1.0.1: Machine learning utilities
- scipy >= 1.7.1: Scientific computing
- numpy: Numerical operations (installed as dependency)
Visualization & Utilities
Visualization & Utilities
- matplotlib >= 3.5.0: Plotting and visualization
- pillow >= 8.4.0: Image loading and processing
- tqdm >= 4.62.3: Progress bars
Similarity Search
Similarity Search
- faiss-cpu: CPU-based similarity search (default)
- faiss-gpu: GPU-accelerated similarity search (optional)
Choose FAISS Backend
By default,
requirements.txt installs faiss-cpu. For significantly faster training and inference, install the GPU version:GPU vs CPU Performance:
- faiss-gpu: 10-50x faster similarity search, requires CUDA
- faiss-cpu: Works everywhere but significantly slower
--faiss_on_gpu flag from training commands.Set PYTHONPATH
PatchCore requires the
src directory to be in your Python path:Alternative: Use env prefix
Alternative: Use env prefix
Instead of setting PYTHONPATH globally, you can prefix each command:
Optional: Install from setup.py
For a more permanent installation, you can install PatchCore as a package:setup.py file which:
- Installs all dependencies from
requirements.txt - Makes the
patchcorepackage importable from anywhere - Allows editable development (
-eflag)
View setup.py
View setup.py
Troubleshooting
ImportError: No module named 'patchcore'
ImportError: No module named 'patchcore'
Solution: Make sure Or run commands from the repository root with the prefix:
PYTHONPATH is set correctly:CUDA out of memory
CUDA out of memory
Solution: Reduce memory usage by:
- Using smaller image sizes:
--imagesize 192instead of--imagesize 224 - Reducing batch size:
--batch_size 1 - Using smaller coreset percentage:
-p 0.01instead of-p 0.1 - Using CPU FAISS (slower but uses less GPU memory)
FAISS installation issues
FAISS installation issues
Problem: Or fall back to CPU version:
faiss-gpu fails to installSolution: Try installing via conda:PyTorch CUDA version mismatch
PyTorch CUDA version mismatch
Problem: PyTorch doesn’t detect your GPUSolution: Install PyTorch matching your CUDA version:Check your CUDA version:
Permission denied errors
Permission denied errors
Solution: Don’t run pip with sudo. Use a virtual environment or:
Hardware Recommendations
Minimum
- GPU: GTX 1080 Ti (11GB)
- CPU: 4 cores
- RAM: 16GB
- Storage: 10GB
Recommended
- GPU: RTX 3090 (24GB)
- CPU: 8+ cores
- RAM: 32GB
- Storage: 50GB
Multi-Dataset
- GPU: A100 (40GB)
- CPU: 16+ cores
- RAM: 64GB
- Storage: 100GB
Verify GPU Setup
Run this diagnostic script to check your setup:Next Steps
Quickstart Guide
Train your first model in minutes
Dataset Setup
Prepare the MVTec AD dataset
Configuration
Understand all training parameters
API Reference
Explore the PatchCore API
