Anko
Anko

Reputation: 11

ImportError: .../detectron/utils/cython_nms.so: undefined symbol: PyFPE_jbuf, Detectron, Caffe2, Anaconda, Cython

I've got import errors when trying to reuse the detectron

Expected Results:

Successful inference

Actual Results

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

Detailed steps to reproduce

<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>

System information

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.

Anything else that seems relevant:
Caffe2 is working just fine, test_spatial_narrow_as_op.py returns 'OK'

From what I found on the web, the problem is that I have different versions of cython, numpy or opencv on my different versions of python and anaconda. But if I remove numpy or opencv from anaconda, then caffe doesn't work anymore, and if I remove cython from my original python packages, then the make command in cd detectron && make fails.

I feel like if I could tell make to use Cython from anaconda and not from the default python it should work.

Upvotes: 1

Views: 959

Answers (2)

Anko
Anko

Reputation: 11

Ok, I found the solution while posting :-p

The solution is to modify the MakeFile in /dectron as follows:

# 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

It will allow the make command to use python from the desired anaconda env and the corresponding Cython installation

Upvotes: 0

user11208213
user11208213

Reputation: 11

This is my trackback:

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

You should:

  1. pip install cython kivy
  2. re-make detectron

Then it can work!

Upvotes: 1

Related Questions