Detectron2: ImportError: /home/xxx/detectron2/detectron2/_C.cpython-36m-x86_64-linux-gnu.so: undefined symbol: cudaSetupArgument

Created on 23 Dec 2019  路  2Comments  路  Source: facebookresearch/detectron2

##Instructions To Reproduce the Issue

  1. Do the same as in INSTALL.md
git clone https://github.com/facebookresearch/detectron2.git
cd detectron2
python setup.py build develop
  1. run the command according to Colab(get input.jpg) and GETTING_STARTED.md :
    wget http://images.cocodataset.org/val2017/000000439715.jpg -O input.jpg

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

  1. get the error:
Traceback (most recent call last):
  File "demo/demo.py", line 11, in <module>
    from detectron2.data.detection_utils import read_image
  File "/home/dengyue/detectron2/detectron2/data/__init__.py", line 4, in <module>
    from .build import (
  File "/home/dengyue/detectron2/detectron2/data/build.py", line 14, in <module>
    from detectron2.structures import BoxMode
  File "/home/dengyue/detectron2/detectron2/structures/__init__.py", line 2, in <module>
    from .boxes import Boxes, BoxMode, pairwise_iou
  File "/home/dengyue/detectron2/detectron2/structures/boxes.py", line 8, in <module>
    from detectron2.layers import cat
  File "/home/dengyue/detectron2/detectron2/layers/__init__.py", line 3, in <module>
    from .deform_conv import DeformConv, ModulatedDeformConv
  File "/home/dengyue/detectron2/detectron2/layers/deform_conv.py", line 10, in <module>
    from detectron2 import _C
ImportError: /home/dengyue/detectron2/detectron2/_C.cpython-36m-x86_64-linux-gnu.so: undefined symbol: cudaSetupArgument

Environment

the output of python -m detectron2.utils.collect_env,


sys.platform linux
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31) [GCC 7.3.0]
Numpy 1.17.4
detectron2._C failed to import
DETECTRON2_ENV_MODULE
PyTorch 1.3.1
PyTorch Debug Build False
torchvision 0.4.2
CUDA available True
GPU 0,1,2,3 Quadro P5000
CUDA_HOME /usr/local/cuda-9.0
NVCC Cuda compilation tools, release 9.0, V9.0.176
Pillow 6.2.1
cv2 4.1.2


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
  • CUDA Runtime 10.1
  • 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_75,code=sm_75;-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=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,

I just searched the solutions and it may be the CUDA version problem. I installed Pytorch with cuda 10.1. And print nvcc -V:
"
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176
"
Can anyone tell me how to solve the problem?Thank you very much.

installation / environment

Most helpful comment

Your nvcc and pytorch's cuda has different versions.
How to fix it is unrelated to detectron2.

All 2 comments

Your nvcc and pytorch's cuda has different versions.
How to fix it is unrelated to detectron2.

Watch out for the way the CUDA_HOME is set in pytorch/utils/cpp_extension.py.

_Issue_: I use pytorch-1.3-py3.6 from conda-c:pytorch, but have a local version of CUDA in usr/local/cuda. For whatever reason, PyTorch set the CUDA_HOME to that path as opposed to None creating the symbol miss-match.

_Tested hack_: Edit pytorch/utils/cpp_extension.py by changing the hard-coded guess. No problems for building and using detectron2, as part of slowfast.

Make sure that you delete the build and *.egg folder from the detectron2 folder. If you created them as part of the installation procedure.

Was this page helpful?
0 / 5 - 0 ratings