今天训练yolo-v2一直出错,就想单步调试以下,因为用printf比较麻烦,选用了gdb调试。
首先修改下Makefile文件,将19行
CC=gcc
改为
CC=gcc -g
然后重新编译,编译完成后运行以下命令进入gdb调试
$gdb darknet
你会看到以下提示
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-51.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/guoyana/my_files/local_install/darknet-v2/darknet...done.
(gdb)
然后设置命令行参数,方法如下
(gdb) set args yolo train ./cfg/yolo-voc.cfg
回车后命令行参数就设置完了,我们用show来看一下
(gdb) show args
Argument list to give program being debugged when it is started is "yolo train ./cfg/yolo-voc.cfg ".
然后我们想在yolo.c文件中设置个断点,等程序运行到指定位置的时候停止,然后单步运行,看错误出在哪一步,设置断点方式如下:
(gdb) b yolo.c:40
Breakpoint 1 at 0x451d44: file ./src/yolo.c, line 40.
然后用r指令来运行程序:
(gdb) r
Starting program: /home/guoyana/my_files/local_install/darknet-v2/darknet yolo train ./cfg/yolo-voc.cfg
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
yolo-voc
layer filters size input output
0 [New Thread 0x7fffc52e1700 (LWP 13524)]
conv 32 3 x 3 / 1 416 x 416 x 3 -> 416 x 416 x 32
1 max 2 x 2 / 2 416 x 416 x 32 -> 208 x 208 x 32
2 conv 64 3 x 3 /