question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Installing Detectron2 on CPU

See original GitHub issue

❓ Questions and Help

Can I install detectron2 on CPU? Currently, I’m getting the following error while building detectron2 on manjaro.

Env:

---------------------  --------------------------------------------------
Python                 3.7.4 (default, Aug 13 2019, 20:35:49) [GCC 7.3.0]
DETECTRON2_ENV_MODULE  <not set>
PyTorch                1.3.0
PyTorch Debug Build    False
CUDA available         False
Pillow                 6.2.0
---------------------  --------------------------------------------------
PyTorch built with:
  - GCC 7.3
  - Intel(R) Math Kernel Library Version 2019.0.4 Product Build 20190411 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v0.20.5 (Git Hash 0125f28c61c1f822fd48570b4c1066f96fcb9b2e)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - NNPACK is enabled
  - Build settings: BLAS=MKL, BUILD_NAMEDTENSOR=OFF, BUILD_TYPE=Release, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -fopenmp -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -O2 -fPIC -Wno-narrowing -Wall -Wextra -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Wno-stringop-overflow, DISABLE_NUMA=1, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=True, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_STATIC_DISPATCH=OFF

Error:

...
g++ -pthread -shared -B /home/harshit/anaconda3/envs/py13/compiler_compat -L/home/harshit/anaconda3/envs/py13/lib -Wl,-rpath=/home/harshit/anaconda3/envs/py13/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.7/home/harshit/PycharmProjects/detectron2/detectron2/layers/csrc/vision.o build/temp.linux-x86_64-3.7/home/harshit/PycharmProjects/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cpu.o build/temp.linux-x86_64-3.7/home/harshit/PycharmProjects/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cpu.o build/temp.linux-x86_64-3.7/home/harshit/PycharmProjects/detectron2/detectron2/layers/csrc/ROIAlign/ROIAlign_cpu.o build/temp.linux-x86_64-3.7/home/harshit/PycharmProjects/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cpu.o -o build/lib.linux-x86_64-3.7/detectron2/_C.cpython-37m-x86_64-linux-gnu.so
/home/harshit/anaconda3/envs/py13/compiler_compat/ld: build/temp.linux-x86_64-3.7/home/harshit/PycharmProjects/detectron2/detectron2/layers/csrc/vision.o: unable to initialize decompress status for section .debug_info
/home/harshit/anaconda3/envs/py13/compiler_compat/ld: build/temp.linux-x86_64-3.7/home/harshit/PycharmProjects/detectron2/detectron2/layers/csrc/vision.o: unable to initialize decompress status for section .debug_info
/home/harshit/anaconda3/envs/py13/compiler_compat/ld: build/temp.linux-x86_64-3.7/home/harshit/PycharmProjects/detectron2/detectron2/layers/csrc/vision.o: unable to initialize decompress status for section .debug_info
/home/harshit/anaconda3/envs/py13/compiler_compat/ld: build/temp.linux-x86_64-3.7/home/harshit/PycharmProjects/detectron2/detectron2/layers/csrc/vision.o: unable to initialize decompress status for section .debug_info
build/temp.linux-x86_64-3.7/home/harshit/PycharmProjects/detectron2/detectron2/layers/csrc/vision.o: file not recognized: file format not recognized
collect2: error: ld returned 1 exit status
error: command 'g++' failed with exit status 1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

13reactions
leopineycommented, Oct 12, 2019

It happened to me when running some tools from the DensePose project that it always tried to compile the model using CUDA, which I don’t have installed because I’m running some experiments on MacOS.

If you want to use CPU for inference you can add the option MODEL.DEVICE cpu to the command you are running, or add that same setting in the configuration file you are using:

MODEL:
  DEVICE: "cpu"
3reactions
kHarshitcommented, Oct 24, 2019

I also have the same error on my MacOS, please how i can use the command MODEL.DEVICE cpu or where should i write to the config file , thank you!

Check https://detectron2.readthedocs.io/tutorials/getting_started.html#inference-with-pre-trained-models i.e. in order to run inference on cpu

python demo/demo.py --config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml \
  --input input1.jpg input2.jpg \
  --opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl \
  MODEL.DEVICE cpu

If you’re talking about the error build/temp.linux-x86_64-3.7/home/harshit/PycharmProjects/detectron2/detectron2/layers/csrc/vision.o: file not recognized: file format not recognized, then I solved it by downgrading binutils to 2.30-5.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Installation — detectron2 0.6 documentation
Install Pre-Built Detectron2 (Linux only)¶ ; 11.1, install python -m pip install detectron2 -f \ https://dl.fbaipublicfiles.com/detectron2/wheels/cu111/torch1.10 ...
Read more >
Installing Detectron2 on a Mac in CPU mode - Knowing.NET
Installing Detectron2 on a Mac in CPU mode · Have conda installed ( brew install conda if not, I suppose) · Create a...
Read more >
Detectron2 : The bare basic end to end tutorial
Next a few prerequisites are installed then a copy of same setup instructions on Detectron2 installation page. The version installed is a CPU...
Read more >
Install Detectron2 on Windows 10 - python - Stack Overflow
7 Answers 7 · Create an anaconda environment (say 'detectron_env'): (note. · Activate detectron_env: conda activate detectron_env · Install cudnn:
Read more >
How to Install Detectron2 | OpenCV Python - YouTube
This Detectron 2 Tutorial will show you how to install Detectron2. We do this using OpenCV in Python for this computer vision tutorial....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found