Installation

Clean setup guide

Use an isolated environment and match dependency versions carefully. This page avoids server-side scripts and is safe static content.

Recommended flow

  1. Create a new virtual environment.
  2. Install PyTorch for your CPU or CUDA target.
  3. Install Detectron2 using a supported wheel or build from source.
  4. Verify inference with a small image before training custom models.
Always check official PyTorch and Detectron2 documentation for version-specific install commands before production use.

Common checks

CheckWhy it matters
Python versionPrevents dependency conflicts and build errors.
CUDA compatibilityGPU builds must match installed drivers and PyTorch.
Clean environmentAvoids mixing old packages from other projects.
Compiler toolsNeeded when building from source.
conda create -n detectron2 python=3.10 -y
conda activate detectron2
# Install PyTorch for your CPU or CUDA target
# Then install Detectron2 from the official instructions
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
# Install matching PyTorch and Detectron2 packages
python - <<'PY'
import torch
print('Torch:', torch.__version__)
print('CUDA available:', torch.cuda.is_available())
PY