1

尝试重用检测器时出现导入错误

预期成绩:

成功推理

实际结果

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返回“OK”

从我在网上找到的内容来看,问题是我在不同版本的pythonanaconda. 但是,如果我从中删除numpyor ,则不再起作用,并且如果我从原始软件包中删除,则 cd detectron && make 中的 make 命令将失败。opencvanacondacaffecythonpython

我觉得如果我可以告诉 make 使用 anaconda 中的 Cython 而不是默认 python 它应该可以工作。

4

2 回答 2

1

这是我的引用:

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. 重新制作探测器

然后它可以工作!

于 2019-03-15T11:00:47.267 回答
0

好的,我在发布时找到了解决方案:-p

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

# 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

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

于 2018-10-19T11:44:30.463 回答