efficient way to debug(analyze) py-caffe using gdb(or ddd)?

717 views
Skip to first unread message

Chan Kim

unread,
Jun 9, 2016, 3:02:53 AM6/9/16
to Caffe Users

hi,

Analyzing the caffe code is taking me so long and I read somewhere they suggest using gdb for that.

I'm analyzing pycaffe and I'm just using prints while running it.

Is there a method to use gdb for py-caffe too? (I know how to use gdb, using ddd and have some experience)

and just in case I would appreciate it if somebody tells me now to use gdb to analyze caffe (for using native caffe interface).


I tried using caffe native commands to execute image classification example. (which I used to do with just tools/demo.py)

I guessed the arguments and get response below. If it runs ok, I could try later with
gdb "command"

What is the wrong part of my caffe test command below?

ckim@stph45:~/Neuro/py-faster-rcnn] caffe test -model models/VGG16/faster_rcnn_alt_opt/faster_rcnn_test.pt -weights data/faster_rcnn_models/VGG16_faster_rcnn_final.caffemodel -gpu data/demo/000456.jpg
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_lexical_cast> >'
  what():  bad lexical cast: source type value could not be interpreted as target
*** Aborted at 1465455359 (unix time) try "date -d @1465455359" if you are using GNU date ***
PC: @       0x3505e32625 (unknown)
*** SIGABRT (@0x3e800000f04) received by PID 3844 (TID 0x7f05ab363720) from PID 3844; stack trace: ***
    @       0x350620f790 (unknown)
    @       0x3505e32625 (unknown)
    @       0x3505e33e05 (unknown)
    @       0x350cabea7d (unknown)
    @       0x350cabcbd6 (unknown)
    @       0x350cabcc03 (unknown)
    @       0x350cabcd22 (unknown)
    @           0x40f141 boost::throw_exception<>()
    @           0x40f3d2 boost::detail::lexical_cast<>()
    @           0x408be2 get_gpus()
    @           0x409576 test()
    @           0x4092c6 main
    @       0x3505e1ed5d (unknown)
    @           0x4081c9 (unknown)
Abort (core dumped)

Thanks!

Chan Kim

unread,
Jun 9, 2016, 4:25:58 AM6/9/16
to Caffe Users
I tried
caffe test -gpu 0 -model models/VGG16/faster_rcnn_alt_opt/faster_rcnn_test.pt -weights data/faster_rcnn_models/VGG16_faster_rcnn_final.caffemodel
but it gives me
.....
I0609 17:23:09.633932  4312 net.cpp:488] rpn_cls_prob_reshape <- rpn_cls_prob
I0609 17:23:09.633940  4312 net.cpp:444] rpn_cls_prob_reshape -> rpn_cls_prob_reshape
I0609 17:23:09.633950  4312 net.cpp:166] Setting up rpn_cls_prob_reshape
I0609 17:23:09.633957  4312 net.cpp:174] Top shape: 1 18 14 14 (3528)
I0609 17:23:09.633963  4312 layer_factory.hpp:76] Creating layer proposal
ImportError: No module named rpn.proposal_layer

at the end.

Cher Keng Heng

unread,
Jul 10, 2016, 4:09:27 AM7/10/16
to Caffe Users
@Chan Kim
I faced the same issue "ImportError: No module named rpn.proposal_layer" when i run in command line. Did you solved it?


On Thursday, 9 June 2016 16:25:58 UTC+8, Chan Kim wrote:
I tried
caffe test -gpu 0 -model models/VGG16/faster_rcnn_alt_opt/faster_rcnn_test.pt -weights data/faster_rcnn_models/VGG16_faster_rcnn_final.caffemodel
but it gives me
.....
I0609 17:23:09.633932  4312 net.cpp:488] rpn_cls_prob_reshape <- rpn_cls_prob
I0609 17:23:09.633940  4312 net.cpp:444] rpn_cls_prob_reshape -> rpn_cls_prob_reshape
I0609 17:23:09.633950  4312 net.cpp:166] Setting up rpn_cls_prob_reshape
I0609 17:23:09.633957  4312 net.cpp:174] Top shape: 1 18 14 14 (3528)
I0609 17:23:09.633963  4312 layer_factory.hpp:76] Creating layer proposal
ImportError: No module named rpn.proposal_layer

at the end.

On Thursday, June 9, 2016 at 4:02:53 PM UTC+9, Chan Kim wrote:

hi,

Analyzing the caffe code is taking me so long and I read somewhere they suggest using gdb for that.

I'm analyzing pycaffe and I'm just using prints while running it.

Is there a method to use gdb for py-caffe too? (I know how to use gdb, using ddd and have some experience)

and just in case I would appreciate it if somebody tells me now to use gdb to analyze caffe (for using native caffe interface).


I tried using caffe native commands to execute image classification example. (which I used to do with just tools/demo.py)

I guessed the arguments and get response below. If it runs ok, I could try later with
gdb "command"

What is the wrong part of my caffe test command below?

ck...@stph45:~/Neuro/py-faster-rcnn] caffe test -model models/VGG16/faster_rcnn_alt_opt/faster_rcnn_test.pt -weights data/faster_rcnn_models/VGG16_faster_rcnn_final.caffemodel -gpu data/demo/000456.jpg

terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_lexical_cast> >'
  what():  bad lexical cast: source type value could not be interpreted as target
*** Aborted at 1465455359 (unix time) try "date -d @1465455359" if you are using GNU date ***
PC: @       0x3505e32625 (unknown)
*** SIGABRT (@0x3e800000f04) received by PID 3844 (TID 0x7f05ab363720) from PID 3844; stack trace: ***
    @       0x350620f790 (unknown)
    @       0x3505e32625 (unknown)
    @       0x3505e33e05 (unknown)
    @       0x350cabea7d (unknown)
    @       0x350cabcbd6 (unknown)
    @       0x350cabcc03 (unknown)
    @       0x350cabcd22 (unknown)
    @           0x40f141 boost::throw_exception<>()
    @           0x40f3d2 boost::detail::lexical_cast<>()
    @           0x408be2 get_gpus()
    @           0x409576 test()
    @           0x4092c6 main
    @       0x3505e1ed5d (unknown)
    @           0x4081c9 (unknown)
Abort (core dumped)

Thanks!

Ji Wang

unread,
Jul 11, 2016, 6:48:14 AM7/11/16
to Cher Keng Heng, Caffe Users
As an alternative, you can use Caffe's c++ interface for debug purpose.
Check $Caffe_ROOT/examples/cpp_classification/classification.cpp for example.
You can set up your debug environment by creating a cmake project.
In CMakeLists.txt, you should use find_package(Caffe) to import the head files and libraries of Caffe.

Good Luck

--
You received this message because you are subscribed to the Google Groups "Caffe Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/06dc2bfe-09a1-475c-9c37-1e9b70358848%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chan Kim

unread,
Aug 11, 2016, 10:05:07 PM8/11/16
to Caffe Users
sorry for too late reponse. I still have the problem. I can debug python code using ddd -pydb prog.py but not both python and c++.
I'm curious if there's somebody debugging c++ and python together out there.

Chan Kim

unread,
Jan 28, 2017, 7:30:22 AM1/28/17
to Caffe Users
I found the solution months ago and I put the answer on stackoverflow.
See http://stackoverflow.com/questions/38898459/debugging-python-and-c-exposed-by-boost-together



On Thursday, June 9, 2016 at 4:02:53 PM UTC+9, Chan Kim wrote:

Zhuotun Zhu

unread,
Mar 20, 2017, 7:47:12 PM3/20/17
to Caffe Users
Hi Chan,

Thank you a lot for your useful instructions for the debug mode of both python and C++.
I followed the instructions but got stuck.
0)  In one terminal, add the pdb.set_trace() before calling Caffe in python and then run the python code, stopped just at the pdb.set_trace();
1) Open another terminal, using ps -aux | grep python to get the pid of the process, let's say, the pid is 21087
2) Then run "gdb python/caffe/_caffe.so 21087" -- here is what I am stuck in, and I didn't have chance to type the "br solver.cpp:225".

The errors after typing "gdb python/caffe/_caffe.so 21087" goes like:
...... (blabla...)
Reading symbols from /lib/x86_64-linux-gnu/libtinfo.so.5...(no debugging symbols found)...done.
Loaded symbols for /lib/x86_64-linux-gnu/libtinfo.so.5
0x00007f05cd9da6cd in read () at ../sysdeps/unix/syscall-template.S:81
81 ../sysdeps/unix/syscall-template.S: No such file or directory.

Then I type "bt" to output the following:
......(blabla...)#35 0x00007f05ce6fd960 in run_mod (arena=0x1288b50, flags=0x7ffeab88cbf0, locals=0x7f05ceb66168, globals=0x7f05ceb66168, filename=<optimized out>, mod=0x12dc8b8) at Python/pythonrun.c:1376
#36 PyRun_FileExFlags (fp=0x1279980, filename=<optimized out>, start=<optimized out>, globals=0x7f05ceb66168, locals=0x7f05ceb66168, closeit=1, flags=0x7ffeab88cbf0) at Python/pythonrun.c:1362
#37 0x00007f05ce6fdb3f in PyRun_SimpleFileExFlags (fp=0x1279980, filename=0x7ffeab88ee51 "/media/zhuotun/Work_HD/Medical/3D-Caffe-DEDICE/workspace/solver_DEDICEEPS.py", closeit=1, flags=0x7ffeab88cbf0)
    at Python/pythonrun.c:948
#38 0x00007f05ce713484 in Py_Main (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:645
#39 0x00007f05cd910f45 in __libc_start_main (main=0x400710, argc=6, argv=0x7ffeab88cd18, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffeab88cd08)
    at libc-start.c:287
#40 0x0000000000400649 in ?? ()
#41 0x00007ffeab88cd08 in ?? ()
#42 0x000000000000001c in ?? ()
#43 0x0000000000000006 in ?? ()
#44 0x00007ffeab88ee4a in ?? ()
#45 0x00007ffeab88ee51 in ?? ()
#46 0x00007ffeab88ee9e in ?? ()
#47 0x00007ffeab88eea1 in ?? ()
#48 0x00007ffeab88eea3 in ?? ()

Could you know what goes wrong here?
Thank you!

Zhuotun


On Saturday, January 28, 2017 at 7:30:22 AM UTC-5, Chan Kim wrote:
I found the solution months ago and I put the answer on stackoverflow.
See http://stackoverflow.com/questions/38898459/debugging-python-and-c-exposed-by-boost-together


On Thursday, June 9, 2016 at 4:02:53 PM UTC+9, Chan Kim wrote:

hi,

Analyzing the caffe code is taking me so long and I read somewhere they suggest using gdb for that.

I'm analyzing pycaffe and I'm just using prints while running it.

Is there a method to use gdb for py-caffe too? (I know how to use gdb, using ddd and have some experience)

and just in case I would appreciate it if somebody tells me now to use gdb to analyze caffe (for using native caffe interface).


I tried using caffe native commands to execute image classification example. (which I used to do with just tools/demo.py)

I guessed the arguments and get response below. If it runs ok, I could try later with
gdb "command"

What is the wrong part of my caffe test command below?

ck...@stph45:~/Neuro/py-faster-rcnn] caffe test -model models/VGG16/faster_rcnn_alt_opt/faster_rcnn_test.pt -weights data/faster_rcnn_models/VGG16_faster_rcnn_final.caffemodel -gpu data/demo/000456.jpg

terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_lexical_cast> >'
  what():  bad lexical cast: source type value could not be interpreted as target
*** Aborted at 1465455359 (unix time) try "date -d @1465455359" if you are using GNU date ***
PC: @       0x3505e32625 (unknown)
*** SIGABRT (@0x3e800000f04) received by PID 3844 (TID 0x7f05ab363720) from PID 3844; stack trace: ***
    @       0x350620f790 (unknown)
    @       0x3505e32625 (unknown)
    @       0x3505e33e05 (unknown)
    @       0x350cabea7d (unknown)
    @       0x350cabcbd6 (unknown)
    @       0x350cabcc03 (unknown)
    @       0x350cabcd22 (unknown)
    @           0x40f141 boost::throw_exception<>()
    @           0x40f3d2 boost::detail::lexical_cast<>()
    @           0x408be2 get_gpus()
    @           0x409576 test()
    @           0x4092c6 main
    @       0x3505e1ed5d (unknown)
    @           0x4081c9 (unknown)
Abort (core dumped)

Thanks!

Reply all
Reply to author
Forward
0 new messages