Getting Detectron2 running on a Mac in CPU mode

At the risk of saying, “Yeah, it’s in the docs,” this is what I did. I think the crucial thing is installed things in the proper order, so I would advise going step-by-step:

  1. Have conda installed (brew install conda if not, I suppose)
  2. Create a conda environment with conda create -n detectron2 python=3.8
  3. conda activate detectron2
  4. Install PyTorch and Torchvision via [this page] choosing “Stable” / “Mac” / “Conda” / “Python” / “CPU”: conda install pytorch torchvision torchaudio -c pytorch
  5. Install OpenCV with conda install -c conda-forge opencv
  6. Install Detectron2 via [this page] python -m pip install 'git+' (Oddly, this didn’t appear to actually compile anything on my M1-based Mac Mini. I did not prepend ARCHFLAGS and CC and CXX as described at the Detectron2 install page. )

Then, you should be able to locally run, e.g., the code from [the tutorial]. But! YOU MUST add cfg.MODEL.DEVICE = 'cpu' to your configuration.

It may be possible to fine-tune Detectron2 using CPU-mode, although it will certainly be much slower than doing so in GPU mode. But for inferencing, CPU-mode seems to work fine.

permalink to this article: "Installing Detectron2 on a Mac in CPU mode"

Last posts

  1. Modularity vs. Machine Learning: Can Software Engineers Adjust?
  2. A Simple 3-Step AzureML Pipeline
  3. Longer Orange 30 SLA Printer Assembly & Initial Impressions
  4. From Whalesharks To Leopard Spheres

    tags: MLSD Futures

  5. Humpback Whale Identification By Deep Learning