msracver / Deformable-ConvNets

Deformable Convolutional Networks
MIT License
4.04k stars 959 forks source link

Can this repo be run on cpu only mxnet? #124

Open SunGaofeng opened 6 years ago

SunGaofeng commented 6 years ago

In ./rfcn/operator_cxx, it seemed that, only gpu version deformable_im2col and deformable_col2im was implemented. The CPU version of these functions were not implemented. How can I run this repo on a cpu only mxnet? Do I need to implement the two functions deformable_im2col and deformable_col2im in /rfcn/operator_cxx/nn/deformable_im2col.h? Any other things I need to do?

Angzz commented 6 years ago

I do not recommend run on CPU,it's too slow

arunbuduri commented 6 years ago

@SunGaofeng we implemented the CPU version and have it running well. @YuwenXiong helped me with one example and I got the others implemented.

For CPU based inference, res101 network takes 2-3 secs for a 800x450 resolution image. I just tested res50 that takes just 1.5 secs for the same 800x450 image. GPU-mode is typically 10 times faster than CPU.

Email me at arun.buduri@gmail.com and I can give you the CPU implementation. I fully don't know the process of submitting the code into mxnet repo (yet) but I figure that out, I'd love to get that into everyone's hands.

smorrel1 commented 6 years ago

+1 on this. Would be great to run validation on the CPU in parallel with training.

arunbuduri commented 6 years ago

Really sorry for the long delay in getting this information to you all.

I have captured the steps (along with the necessary source code) here - https://drive.google.com/open?id=1P8vYr9ekWp3NK8_N2bs8sl7jRT39m25I

I have tested this on Windows, Mac, Linux, and Ubuntu.

Please let me know if you have any questions.

ice-pice commented 6 years ago

@arunbuduri Thanks for the detailed instructions. It works!

MuhammadAliShahzad commented 4 years ago

Hi, @YuwenXiong @arunbuduri I looked at the document that you shared and tried replicating the steps for FPN DCN but it seems that there is a missing link. The guide that you provided works for RFCNs.

When I update the code and run, it gives the following exception when it tries to load the model

Stack trace returned 10 entries:
[bt] (0) /usr/local/lib/python2.7/dist-packages/mxnet-0.10.1-py2.7.egg/mxnet/libmxnet.so(_ZN4dmlc15LogMessageFatalD1Ev+0x41) [0x7fc5fc5a6271]
[bt] (1) /usr/local/lib/python2.7/dist-packages/mxnet-0.10.1-py2.7.egg/mxnet/libmxnet.so(_ZN5mxnet7NDArray4LoadEPN4dmlc6StreamEPSt6vectorIS0_SaIS0_EEPS4_INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISD_EE+0x187) [0x7fc5fcfdda07]
[bt] (2) /usr/local/lib/python2.7/dist-packages/mxnet-0.10.1-py2.7.egg/mxnet/libmxnet.so(MXNDArrayLoad+0x38f) [0x7fc5fd32483f]
[bt] (3) /usr/lib/x86_64-linux-gnu/libffi.so.6(ffi_call_unix64+0x4c) [0x7fc5ffd7cdae]
[bt] (4) /usr/lib/x86_64-linux-gnu/libffi.so.6(ffi_call+0x22f) [0x7fc5ffd7c71f]
[bt] (5) /usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so(_ctypes_callproc+0x2a4) [0x7fc5fff8fcc4]
[bt] (6) /usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so(+0x106c5) [0x7fc5fff8f6c5]
[bt] (7) python(PyEval_EvalFrameEx+0x54b0) [0x55c54396cb20]
[bt] (8) python(PyEval_EvalCodeEx+0x58a) [0x55c5439652aa]
[bt] (9) python(PyEval_EvalFrameEx+0x5d2e) [0x55c54396d39e]

Traceback (most recent call last):
  File "abc-raw-detection.py", line 482, in <module>
    tableDetector.setupModel()
  File "abc-raw-detection.py", line 344, in setupModel
    arg_params, aux_params = load_param("/src/Deformable-ConvNets/model/abc_raw/fpn_abc_str_2cls", 100, process=True)
  File "/src/Deformable-ConvNets/utils/load_model.py", line 56, in load_param
    arg_params, aux_params = load_checkpoint(prefix, epoch)
  File "/src/Deformable-ConvNets/utils/load_model.py", line 22, in load_checkpoint
    save_dict = mx.nd.load('%s-%04d.params' % (prefix, epoch))
  File "/usr/local/lib/python2.7/dist-packages/mxnet-0.10.1-py2.7.egg/mxnet/ndarray.py", line 2129, in load
    ctypes.byref(names)))
  File "/usr/local/lib/python2.7/dist-packages/mxnet-0.10.1-py2.7.egg/mxnet/base.py", line 85, in check_call
    raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [16:40:57] src/ndarray/ndarray.cc:738: Check failed: fi->Read(data) Invalid NDArray file format

Stack trace returned 10 entries:
[bt] (0) /usr/local/lib/python2.7/dist-packages/mxnet-0.10.1-py2.7.egg/mxnet/libmxnet.so(_ZN4dmlc15LogMessageFatalD1Ev+0x41) [0x7fc5fc5a6271]
[bt] (1) /usr/local/lib/python2.7/dist-packages/mxnet-0.10.1-py2.7.egg/mxnet/libmxnet.so(_ZN5mxnet7NDArray4LoadEPN4dmlc6StreamEPSt6vectorIS0_SaIS0_EEPS4_INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISD_EE+0x187) [0x7fc5fcfdda07]
[bt] (2) /usr/local/lib/python2.7/dist-packages/mxnet-0.10.1-py2.7.egg/mxnet/libmxnet.so(MXNDArrayLoad+0x38f) [0x7fc5fd32483f]
[bt] (3) /usr/lib/x86_64-linux-gnu/libffi.so.6(ffi_call_unix64+0x4c) [0x7fc5ffd7cdae]
[bt] (4) /usr/lib/x86_64-linux-gnu/libffi.so.6(ffi_call+0x22f) [0x7fc5ffd7c71f]
[bt] (5) /usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so(_ctypes_callproc+0x2a4) [0x7fc5fff8fcc4]
[bt] (6) /usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so(+0x106c5) [0x7fc5fff8f6c5]
[bt] (7) python(PyEval_EvalFrameEx+0x54b0) [0x55c54396cb20]
[bt] (8) python(PyEval_EvalCodeEx+0x58a) [0x55c5439652aa]
[bt] (9) python(PyEval_EvalFrameEx+0x5d2e) [0x55c54396d39e]