msracver / Deformable-ConvNets

Deformable Convolutional Networks
MIT License
4.05k stars 957 forks source link

pip install yield "AttributeError: 'module' object has no attribute 'DeformableConvolution'" #98

Closed PPACI closed 7 years ago

PPACI commented 7 years ago

Hi everyone.

I'm trying to install MXNet. Following the documentation, specially the quick-start, i tried to install with pip.

But when trying to start the demo, i got the AttributeError: 'module' object has no attribute 'DeformableConvolution' error.

Q: It says AttributeError: 'module' object has no attribute 'DeformableConvolution'.

A: This is because either

you forget to copy the operators to your MXNet folder

or you copy to the wrong path

or you forget to re-compile

or you install the wrong MXNet

Please print mxnet.__path__ to make sure you use correct MXNet

My question is : As i saw a commit on this repository indicating that the code has been updated for MXNet 0.10, will it work if i clone MXNet at correct commit and recompiling it ?

The code is tested on official MXNet@(commit 62ecb60) with the extra operators for Deformable ConvNets.
After MXNet@(commit ce2bca6) the offical MXNet support all operators for Deformable ConvNets.

If it could help, here is what i did :

(mxnet) pierre@PC35$ pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
backports.functools-lru-cache (1.4)
certifi (2016.2.28)
cycler (0.10.0)
Cython (0.27.1)
easydict (1.7)
graphviz (0.8.1)
matplotlib (2.1.0)
numpy (1.13.3)
olefile (0.44)
opencv-python (3.3.0.10)
Pillow (4.3.0)
pip (9.0.1)
pyparsing (2.2.0)
python-dateutil (2.6.1)
pytz (2017.2)
PyYAML (3.12)
setuptools (36.4.0)
six (1.11.0)
subprocess32 (3.2.7)
wheel (0.29.0)
(mxnet) pierre@PC35$ pip install -r requirements.txt 
Requirement already satisfied: Cython in /home/pierre/miniconda3/envs/mxnet/lib/python2.7/site-packages (from -r requirements.txt (line 1))
Requirement already satisfied: EasyDict in /home/pierre/miniconda3/envs/mxnet/lib/python2.7/site-packages (from -r requirements.txt (line 2))
Requirement already satisfied: opencv-python in /home/pierre/miniconda3/envs/mxnet/lib/python2.7/site-packages (from -r requirements.txt (line 3))
Collecting mxnet-cu80==0.10.0 (from -r requirements.txt (line 4))
  Using cached mxnet_cu80-0.10.0-py2.py3-none-manylinux1_x86_64.whl
Requirement already satisfied: numpy>=1.11.1 in /home/pierre/miniconda3/envs/mxnet/lib/python2.7/site-packages (from opencv-python->-r requirements.txt (line 3))
Installing collected packages: mxnet-cu80
Successfully installed mxnet-cu80-0.10.0
(mxnet) pierre@PC35$ python ./rfcn/demo.py 
{'CLASS_AGNOSTIC': True,
 'MXNET_VERSION': 'mxnet',
 'SCALES': [(600, 1000)],
 'TEST': {'BATCH_IMAGES': 1,
          'CXX_PROPOSAL': False,
          'HAS_RPN': True,
{...}
             'pretrained_epoch': 0},
 'output_path': './output/rfcn',
 'symbol': 'resnet_v1_101_rfcn'}
Traceback (most recent call last):
  File "./rfcn/demo.py", line 129, in <module>
    main()
  File "./rfcn/demo.py", line 50, in main
    sym = sym_instance.get_symbol(config, is_train=False)
  File "/home/pierre/Dev/Earthlab/Deformable-ConvNets/rfcn/symbols/resnet_v1_101_rfcn_dcn.py", line 725, in get_symbol
    relu1 = self.get_resnet_v1_conv5(conv_feat)
  File "/home/pierre/Dev/Earthlab/Deformable-ConvNets/rfcn/symbols/resnet_v1_101_rfcn_dcn.py", line 633, in get_resnet_v1_conv5
    res5a_branch2b = mx.contrib.symbol.DeformableConvolution(name='res5a_branch2b', data=res5a_branch2a_relu, offset=res5a_branch2b_offset,
AttributeError: 'module' object has no attribute 'DeformableConvolution'

I'm running under Ubuntu 16.04 with cuda8

arunbuduri commented 7 years ago

Did you rebuild mxnet after you copied the operators? Once you rebuilt it, did you run "sudo python setup.py install" in the mxnet/python folder?

There is also another note in the README that the latest MXNET code has all the needed operators.

After MXNet@(commit ce2bca6) the offical MXNet support all operators for Deformable ConvNets.

I have tested with the latest mxnet code and it works well. I have tested on Windows, Ubuntu and Mac.

So unless you need that old commit, you can take the latest mxnet code and build/install it.

PPACI commented 7 years ago

I, thank for the quick response. Firstly i tried with pip, so not rebuild and anything. As i said, it didn't worked. Then i rebuild from the source code with the specified commit (MXNet 0.9.5), with the operators, and it worked correctly.

So my problem is resolved... But the documentation seems unclear to me. So if I had downloaded the latest version of MXNet from pip and the latest commit of this repo, it should have worked ? I mean, without copying anything ?

And really guys, thank for the excellent work on this implementation. It's honestly one of the best I've ever saw.

arunbuduri commented 7 years ago

That does seem strange. I have not tried using pip to install the latest mxnet. I'm rebuilding latest mxnet with CPU-mode implementation for operators.

You are correct. If pip installed the latest mxnet (can you verify version), it should have worked without copying any operators and rebuilding.

I will try it with pip and let you know.

PPACI commented 7 years ago

Tommorow I will try to rebuild with the latest MXNet to confirm that it work on my side. I will also give you the version installed by pip.

YuwenXiong commented 7 years ago

Please print mxnet.__path__ to make sure you use correct MXNet. It should contain strings like 'site-package' and '0.10.0'.

PPACI commented 7 years ago

Ok, i got results. I retried with the latest pip version (which is now 0.11.0). And it worked correctly. I must have failed something with the previous pip install I think. Sorry for the "false" issue.