Installation Guide

This guide provides detailed instructions for setting up the project environment. We recommend using conda for environment management to ensure compatibility of dependencies.

Prerequisites

  • Python 3.8 or higher.
  • A conda installation (Miniconda or Anaconda).
  • NVIDIA GPU with CUDA support for training and inference.

Step 1: Create a Conda Environment

First, create and activate a new conda environment. This project is tested with Python 3.10.

conda create -n ovsam_env python=3.10
conda activate ovsam_env

Step 2: Install PyTorch

Install PyTorch with the appropriate CUDA version. The following command installs PyTorch for CUDA 12.1. Please adjust the version numbers if you are using a different CUDA toolkit.

conda install pytorch torchvision torchaudio pytorch-cuda=12.1 cuda -c pytorch -c "nvidia/label/cuda-12.1.0" -c "nvidia/label/cuda-12.1.1"

Step 3: Install OpenMMLab Dependencies

This project relies on several libraries from the OpenMMLab ecosystem. Install them in the specified order.

1. MMEngine

python -m pip install https://github.com/open-mmlab/mmengine/archive/refs/tags/v0.8.5.zip

2. MMCV

Installing mmcv requires compiling CUDA ops. You need to determine your GPU's Compute Capability (COMCAP) and set it as an environment variable.

To find your COMCAP, you can ask ChatGPT: What is the Compute Capability of NVIDIA {YOUR GPU MODEL}? Please only output the number, without text. For example, for an NVIDIA A100, the value is 8.0.

# Replace {COMCAP} with your GPU's compute capability (e.g., 8.0, 8.6, etc.)
export COMCAP=8.0

TORCH_CUDA_ARCH_LIST="${COMCAP}" \
TORCH_NVCC_FLAGS="-Xfatbin -compress-all" \
CUDA_HOME=$(dirname $(dirname $(which nvcc))) \
LD_LIBRARY_PATH=$(dirname $(dirname $(which nvcc)))/lib \
MMCV_WITH_OPS=1 FORCE_CUDA=1 \
python -m pip install git+https://github.com/open-mmlab/mmcv.git@4f65f91db6502d990ce2ee5de0337441fb69dd10

3. Other MMLab Packages

Install mmdetection, mmsegmentation, and mmpretrain.

python -m pip install \
https://github.com/open-mmlab/mmdetection/archive/refs/tags/v3.1.0.zip \
https://github.com/open-mmlab/mmsegmentation/archive/refs/tags/v1.1.1.zip \
https://github.com/open-mmlab/mmpretrain/archive/refs/tags/v1.0.1.zip

Step 4: Install Extra Packages

Finally, install the remaining packages required by the project.

python -m pip install git+https://github.com/cocodataset/panopticapi.git \
git+https://github.com/HarborYuan/lvis-api.git \
tqdm terminaltables pycocotools scipy tqdm ftfy regex timm scikit-image kornia

Step 5: Development Dependencies (Optional)

If you plan to contribute to the project or run tests, install the development dependencies using Poetry.

# Ensure you have poetry installed: pip install poetry
poetry install --with dev

Your environment is now fully set up and ready for running experiments.