Detectron2: ImportError: libtorch_cpu.so: cannot open shared object file: No such file or directory

Created on 5 May 2020  Â·  9Comments  Â·  Source: facebookresearch/detectron2

I followed all instructions of INSTALLATION.md and I still I am getting

from detectron2 import _C
ImportError: libtorch_cpu.so: cannot open shared object file: No such file or directory

However, I am able to import detectron2 from any directory outside detectron2's root directory

I tried running -
python demo.py --config-file ../configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input images.jpeg --opts MODEL.WEIGHTS ../COCO-InstanceSegmentation/model_final_f10217.pkl

  1. what you observed (including __full logs__):
    ```Traceback (most recent call last):
    File "demo.py", line 11, in
    from detectron2.data.detection_utils import read_image
    File "/home/shiva/work/object_rotated/lib/python3.8/site-packages/detectron2/data/__init__.py", line 4, in
    from .build import (
    File "/home/shiva/work/object_rotated/lib/python3.8/site-packages/detectron2/data/build.py", line 14, in
    from detectron2.structures import BoxMode
    File "/home/shiva/work/object_rotated/lib/python3.8/site-packages/detectron2/structures/__init__.py", line 6, in
    from .keypoints import Keypoints, heatmaps_to_keypoints
    File "/home/shiva/work/object_rotated/lib/python3.8/site-packages/detectron2/structures/keypoints.py", line 6, in
    from detectron2.layers import interpolate
    File "/home/shiva/work/object_rotated/lib/python3.8/site-packages/detectron2/layers/__init__.py", line 3, in
    from .deform_conv import DeformConv, ModulatedDeformConv
    File "/home/shiva/work/object_rotated/lib/python3.8/site-packages/detectron2/layers/deform_conv.py", line 10, in
    from detectron2 import _C
    ImportError: libtorch_cpu.so: cannot open shared object file: No such file or directory

Expected behavior:

I expected sample output of detectron2 by runnning demo.py

Environment:


sys.platform linux
Python 3.8.2 (default, Apr 27 2020, 15:53:34) [GCC 9.3.0]
numpy 1.18.4
detectron2 0.1.2 @/home/shiva/work/object_rotated/lib/python3.8/site-packages/detectron2
detectron2._C failed to import
DETECTRON2_ENV_MODULE
PyTorch 1.4.0+cu92 @/home/shiva/work/object_rotated/lib/python3.8/site-packages/torch
PyTorch debug build False
CUDA available True
GPU 0 GeForce 940MX
CUDA_HOME /usr
NVCC Cuda compilation tools, release 10.1, V10.1.243
Pillow 7.1.2
torchvision 0.5.0+cu92 @/home/shiva/work/object_rotated/lib/python3.8/site-packages/torchvision
torchvision arch flags sm_35, sm_50, sm_60, sm_70
fvcore 0.1.dev200505
cv2 4.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.21.1 (Git Hash 7d2fd500bc78936d1d648ca713b901012f470dbc)
  • OpenMP 201511 (a.k.a. OpenMP 4.5)
  • NNPACK is enabled
  • CUDA Runtime 9.2
  • NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_37,code=compute_37
  • CuDNN 7.6.3
  • Magma 2.5.1
  • 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=ON, 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,

```

I tried common installation issues but my error was not resolved
However I am able to import detectron2 from any directory outside detectron2's root directory

installation / environment

All 9 comments

It seems you're using a pre-built detectron2. As the installation instruction says:

Such installation has to be used with certain version of official PyTorch release. See releases for requirements.

Yours did not meet the requirements.

I tried it with Detectron2 v0.1 Release
As this release says PyTorch version 1.4 is required
Still getting same error

from detectron2 import _C

ImportError: libtorch_cpu.so: cannot open shared object file: No such file or directory

It seems you're using a pre-built detectron2. As the installation instruction says:

Such installation has to be used with certain version of official PyTorch release. See releases for requirements.

Yours did not meet the requirements.

"""
I tried it with Detectron2 v0.1 Release
As this release says PyTorch version 1.4 is required
Still getting same error
"""
from detectron2 import _C
ImportError: libtorch_cpu.so: cannot open shared object file: No such file or directory

Your log says you installed detectron2 0.1.2

Your log says you installed detectron2 0.1.2

I tried again
Nevertheless I built detectron2 from source and issue was resolved
Thank You :)

This issue was resolved by using tag v0.1.1

I resolved this issue by updating pytroch from 1.4.0 to 1.5.0

This issue was resolved by using tag v0.1.1
@songruoning
hello.
Could u tell me how to use tag v0.1.1?

You can see branch, there is a branch named v0.1.1 pull that and use it.

On Thu, Jul 16, 2020 at 12:27 PM Ricelll notifications@github.com wrote:

This issue was resolved by using tag v0.1.1
@songruoning https://github.com/songruoning
hello.
Could u tell me how to use tag v0.1.1?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/facebookresearch/detectron2/issues/1365#issuecomment-659199315,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AJW4UPLLVUDJXCCGK5SAUK3R32QFXANCNFSM4MZ3TPCA
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marcoippolito picture marcoippolito  Â·  4Comments

wytcsuch picture wytcsuch  Â·  4Comments

invisprints picture invisprints  Â·  4Comments

Cold-Winter picture Cold-Winter  Â·  3Comments

jinfagang picture jinfagang  Â·  3Comments