Installation
This guide will walk you through installing SAM 3 and its dependencies on your system.Prerequisites
Before installing SAM 3, ensure your system meets the following requirements:- Python: 3.12 or higher (3.8+ supported, 3.12 recommended)
- PyTorch: 2.7 or higher
- CUDA: CUDA-compatible GPU with CUDA 12.6 or higher
- Operating System: Linux (recommended), macOS, or Windows with WSL
For optimal performance, we recommend using a GPU with at least 16GB of VRAM. SAM 3 has 848M parameters and benefits from GPU acceleration.
Installation Steps
Install PyTorch with CUDA Support
Install PyTorch 2.7 with CUDA 12.6 support:Verify your PyTorch installation:
Install SAM 3
Install SAM 3 in editable mode:This will install SAM 3 along with its core dependencies:
timm>=1.0.17- PyTorch Image Modelsnumpy>=1.26,<2- Numerical computingtqdm- Progress barsftfy==6.1.1- Text encoding fixesregex- Regular expressionsiopath>=0.1.10- File I/O utilitiestyping_extensions- Type hintshuggingface_hub- Model downloads
Install Optional Dependencies
Depending on your use case, install additional dependencies:Notebooks dependencies include:
matplotlib,jupyter,notebook- Jupyter environmentipywidgets,ipycanvas,ipympl- Interactive widgetspycocotools- COCO dataset toolsdecord,opencv-python- Video processingeinops,scikit-image,scikit-learn- Image processing
pytest,pytest-cov- Testingblack,ufmt,usort- Code formattingyt-dlp,pandas- Data processing
hydra-core,submitit- Job managementtensorboard- Training visualizationscipy,torchmetrics- Metrics and optimization
Checkpoint Access
Before using SAM 3, you need to request access to the model checkpoints.Request Checkpoint Access
Request access to the SAM 3 checkpoints on Hugging Face:
- Visit the SAM 3 Hugging Face repository
- Click “Request Access” and follow the prompts
- Wait for approval (usually granted within a few hours)
Authenticate with Hugging Face
Once approved, authenticate your local environment:When prompted, enter your Hugging Face access token. You can generate a token at huggingface.co/settings/tokens.
The authentication token is stored locally and used automatically when downloading checkpoints.
Verify Installation
Verify that SAM 3 is installed correctly:Troubleshooting
CUDA out of memory errors
CUDA out of memory errors
If you encounter CUDA out of memory errors:
- Reduce batch size or image resolution
- Use mixed precision training with
torch.autocast - Ensure no other processes are using GPU memory
- Consider using a GPU with more VRAM
Import errors
Import errors
If you get import errors:
- Ensure you’re using the correct Conda environment:
conda activate sam3 - Verify all dependencies are installed:
pip list | grep sam3 - Try reinstalling:
pip uninstall sam3 && pip install -e .
Checkpoint download failures
Checkpoint download failures
If checkpoint downloads fail:
- Verify you have access to the Hugging Face repository
- Check your authentication:
huggingface-cli whoami - Ensure you have a stable internet connection
- Try downloading manually from the Hugging Face hub
PyTorch CUDA version mismatch
PyTorch CUDA version mismatch
If PyTorch doesn’t detect CUDA:
- Verify CUDA is installed:
nvidia-smi - Ensure PyTorch CUDA version matches your system CUDA
- Reinstall PyTorch with the correct CUDA version
- Check the PyTorch installation guide
Next Steps
Now that SAM 3 is installed, you’re ready to run your first segmentation!Quick Start Guide
Learn how to perform your first image and video segmentation with SAM 3