ImportError:... / detectron / utils / cython_nms.so:未定义符号:PyFPE_jbuf,Detectron,Caffe2,Anaconda,Cython

时间:2018-10-19 11:40:47

标签: python-2.7 cython caffe2

尝试重用detectron

时出现导入错误

预期结果:

成功推断

实际结果

Traceback (most recent call last):

File "infer_simple.py", line 44, in <module>
     import detectron.core.test_engine as infer_engine
 File ".../detectron/core/test_engine.py", line 35, in <module>
     from detectron.core.rpn_generator import generate_rpn_on_dataset
 File ".../detectron/core/rpn_generator.py", line 42, in <module>
     from detectron.datasets import task_evaluation
 File ".../detectron/datasets/task_evaluation.py", line 47, in <module>
     import detectron.datasets.json_dataset_evaluator as json_dataset_evaluator
 File ".../detectron/datasets/json_dataset_evaluator.py", line 34, in <module>
     import detectron.utils.boxes as box_utils

 File ".../detectron/utils/boxes.py", line 52, in <module>
     import detectron.utils.cython_nms as cython_nms
     ImportError: .../detectron/utils/cython_nms.so: undefined symbol: PyFPE_jbuf

详细的复制步骤

<code>conda install pytorch-nightly -c pytorch</code><br>
DETECTRON=/path/to/clone/detectron<br>
<code>git clone https://github.com/facebookresearch/detectron $DETECTRON</code><br>
<code>pip install -r $DETECTRON/requirements.txt</code><br>
<code>cd $DETECTRON && make <code>
<code>python $DETECTRON/detectron/tools/infer_simple.py</code>

系统信息

Operating system: Ubuntu 16.04
Compiler version: Cmake 3.12.0
CUDA version: 9.2
cuDNN version: 9.0
NVIDIA driver version: 396.37
GPU model: Nvidia K80
PYTHONPATH: empty

python --version
> Python 2.7.15 :: Anaconda, Inc.

其他似乎相关的内容:
Caffe2运行正常,test_spatial_narrow_as_op.py返回“确定”

从网上发现的问题是,我的pythonanaconda的不同版本上都有cython,numpy或opencv的不同版本。但是,如果我从numpy中删除了opencvanaconda,则caffe不再起作用,并且如果我从原来的{{1}中删除了cython }软件包,则cd detectron && make中的make命令失败。

我觉得如果我能告诉make使用anaconda的Cython,而不是默认的python,那应该可以。

2 个答案:

答案 0 :(得分:0)

好,我在发布:-p

时找到了解决方案

解决方案是如下修改/dectron中的MakeFile:

# Don't use the --user flag for setup.py develop mode with virtualenv.
DEV_USER_FLAG=$(shell python -c "import sys; print('' if hasattr(sys, 'real_prefix') else '--user')")
PYTHON_EXE=/home/[username]/anaconda3/envs/[myenv]/bin/python2.7

.PHONY: default
default: dev

.PHONY: install
install:
    $(PYTHON_EXE) setup.py install

.PHONY: ops
ops:
    mkdir -p build && cd build && cmake .. && make -j$(shell nproc)

.PHONY: dev
dev:
    $(PYTHON_EXE) setup.py develop $(DEV_USER_FLAG)

.PHONY: clean
clean:
    $(PYTHON_EXE) setup.py develop --uninstall $(DEV_USER_FLAG)
    rm -rf build

它将允许make命令从所需的anaconda env和相应的python安装中使用Cython

答案 1 :(得分:0)

这是我的引用:

Traceback (most recent call last):
  File "tools/tracking/greedy_tracking_from_raw_dets.py", line 8, in <module>
    from vdetlib.vdet.track import greedily_track_from_raw_dets, fcn_tracker
  File "./vdetlib/vdet/track.py", line 13, in <module>
    from ..utils.cython_nms import track_det_nms
ImportError: ./vdetlib/utils/cython_nms.so: undefined symbol: PyFPE_jbuf

您应该:

  1. pip install cython kivy
  2. 重新制作侦探器

那就可以了!