pgigioli / darknet_ros

YOLO integration with ROS for real-time object detection
51 stars 23 forks source link

error with Segmentation fault (core dumped) when rosrun ROS_interface #7

Closed HankerSia closed 6 years ago

HankerSia commented 6 years ago

Hello, i am sorry to disturb you, i want to use the darknet_ros on ubuntu16.04 with a TITAN Xp GPU and ros kinetic , and i have passed the catkin_make, besides, i changed the related path as following: char cfg = "/home/robot/catkin_ws/src/darknet_ros/cfg/tiny-yolo.cfg"; char weights = "/home/robot/catkin_ws/src/darknet_ros/tiny-yolo.weights"; float thresh = 0.2; const std::string CAMERA_TOPIC_NAME = "/kinect2/qhd/image_color"; but when I rosrun the ROS_interface, it always turns up "Segmentation fault (core dumped)", and i tried to give the net an image instead of capturing the image from the topic, as following: void cameraCallback(const sensor_msgs::ImageConstPtr& msg) { std::cout << "usb image received" << std::endl; cv_bridge::CvImagePtr cam_image; cam_image_copy = cv::imread("/home/robot/Pictures/tar_test.jpeg", 1 ); ROS_INFO("IMAGE READED"); / try { cam_image = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::BGR8); } catch (cv_bridge::Exception& e) { ROS_ERROR("cv_bridge exception: %s", e.what()); return; } / //if (cam_image) //{ //cam_image_copy = cam_image->image.clone(); demo_yolo(); //} return; }

At last, the error did not vanish, as following: YOLO demo 0: Convolutional Layer: 448 x 448 x 3 image, 16 filters -> 448 x 448 x 16 image 1: Maxpool Layer: 448 x 448 x 16 image, 2 size, 2 stride 2: Convolutional Layer: 224 x 224 x 16 image, 32 filters -> 224 x 224 x 32 image 3: Maxpool Layer: 224 x 224 x 32 image, 2 size, 2 stride 4: Convolutional Layer: 112 x 112 x 32 image, 64 filters -> 112 x 112 x 64 image 5: Maxpool Layer: 112 x 112 x 64 image, 2 size, 2 stride 6: Convolutional Layer: 56 x 56 x 64 image, 128 filters -> 56 x 56 x 128 image 7: Maxpool Layer: 56 x 56 x 128 image, 2 size, 2 stride 8: Convolutional Layer: 28 x 28 x 128 image, 256 filters -> 28 x 28 x 256 image 9: Maxpool Layer: 28 x 28 x 256 image, 2 size, 2 stride 10: Convolutional Layer: 14 x 14 x 256 image, 512 filters -> 14 x 14 x 512 image 11: Maxpool Layer: 14 x 14 x 512 image, 2 size, 2 stride 12: Convolutional Layer: 7 x 7 x 512 image, 1024 filters -> 7 x 7 x 1024 image 13: Convolutional Layer: 7 x 7 x 1024 image, 256 filters -> 7 x 7 x 256 image 14: Connected Layer: 12544 inputs, 1470 outputs 15: Detection Layer forced: Using default '0' Loading weights from /home/robot/catkin_ws/src/darknet_ros/tiny-yolo.weights...Done! usb image received [ INFO] [1508989693.852160839]: IMAGE READED CUDA Error: invalid device function ROS_interface: /home/robot/catkin_ws/src/darknet_ros/src/cuda.c:21: check_error: Assertion `0' failed. Aborted (core dumped)

And parts of the dmesg output is as following: [ 42.874807] [drm:nvidia_drm_gem_prime_fence_force_signal [nvidia_drm]] ERROR [nvidia-drm] [GPU ID 0x00000300] Failed to lookup gem object for fence attach: 0x00000004 [ 42.875341] [drm:nvidia_drm_gem_prime_fence_force_signal [nvidia_drm]] ERROR [nvidia-drm] [GPU ID 0x00000300] Failed to lookup gem object for fence attach: 0x00000004 [ 195.291960] xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 2 with no TDs queued? [ 196.056566] show_signal_msg: 13 callbacks suppressed [ 196.056569] ROS_interface[3557]: segfault at 0 ip (null) sp 00007ffc11866698 error 14 in ROS_interface[400000+15d000] [ 227.933021] xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 2 with no TDs queued? [ 228.717928] traps: ROS_interface[3598] general protection ip:7f3cad8aa4e5 sp:7fffa796b340 error:0 [ 228.717933] in libopencv_core.so.2.4.13[7f3cad73f000+294000] [ 463.603282] xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 2 with no TDs queued? [ 464.359962] ROS_interface[4115]: segfault at 0 ip (null) sp 00007ffd583054b8 error 14 in ROS_interface[400000+15d000] [ 614.896886] xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 2 with no TDs queued? [ 837.687950] xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 2 with no TDs queued? [ 838.471002] yolo_object_det[4614]: segfault at 0 ip (null) sp 00007ffc7d34c3f8 error 14 in yolo_object_detector[400000+16c000] [ 1560.863665] xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 2 with no TDs queued? [ 1561.649718] ROS_interface[5293]: segfault at 0 ip (null) sp 00007ffd703e2208 error 14 in ROS_interface[400000+15d000] [ 1566.871426] xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 2 with no TDs queued? [ 1567.650238] yolo_object_det[5323]: segfault at 2010040 ip 00007fcb9f68d4e5 sp 00007ffc8e6f8060 error 4 in libopencv_core.so.2.4.13[7fcb9f522000+294000] [ 1628.468934] xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 2 with no TDs queued? [ 1629.245958] ROS_interface[5635]: segfault at 0 ip (null) sp 00007fffe98ccf58 error 14 in ROS_interface[400000+15d000] [ 1634.021019] xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 2 with no TDs queued? [ 1634.076945] xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 2 with no TDs queued? [ 1634.845787] yolo_object_det[5665]: segfault at 0 ip (null) sp 00007ffed6177f98 error 14 in yolo_object_detector[400000+16c000] [ 2354.325439] xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 2 with no TDs queued? [ 5297.432565] perf: interrupt took too long (2504 > 2500), lowering kernel.perf_event_max_sample_rate to 79750 [ 5566.135706] xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 2 with no TDs queued? [ 5566.874218] ROS_interface[10371]: segfault at 0 ip (null) sp 00007ffcb2b9e3e8 error 14 in ROS_interface[400000+15d000] [ 5610.947937] xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 2 with no TDs queued? [ 5611.714759] ROS_interface[10408]: segfault at 0 ip (null) sp 00007ffc912ba288 error 14 in ROS_interface[400000+15d000] [ 5619.312463] xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 2 with no TDs queued? [ 5620.076744] ROS_interface[10699]: segfault at 0 ip (null) sp 00007ffd26f9f608 error 14 in ROS_interface[400000+15d000] [ 5678.754142] xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 2 with no TDs queued? [ 5678.757050] xhci_hcd 0000:00:14.0: WARN Event TRB for slot 3 ep 2 with no TDs queued? [ 5679.501654] ROS_interface[10993]: segfault at 0 ip (null) sp 00007ffd0e1512d8 error 14 in ROS_interface[400000+15e000]

i really need your help. Look forward to your soonest reply. yours sincerely Hanker.

pgigioli commented 6 years ago

In the CMakeList.txt, try adding these lines between lines 29 and 30

-gencode arch=compute_61,code=sm_61 -gencode arch=compute_62,code=sm_62

The current CMakeList.txt doesn't support your GPU architecture. Let me know how that goes.

HankerSia commented 6 years ago

Hello, thanks for your advices, i test the code snippets in the first comment , and the error didn't turn up when running the ROS_interface node. But when i use the tiny-yolo.cfg and tiny-yolo.weights, it did give any result( i have tested the image using "./darknet detect cfg/tiny-yolo.cfg tiny-yolo.weights data/tar_test.jpeg", and it could mark many targets), as following: FPS:15 Objects:

FPS:15 Objects:

usb image received ......

Then, i changed to use the yolo.cfg and the yolo.weights, and the outputs is as following: ...... 32: Detection Layer forced: Using default '0' Loading weights from /home/robot/catkin_ws/src/darknet_ros/yolo.weights...Done! usb image received

FPS:0 Objects:

sofa: 435333180162771165118464.00 sofa: 66501539206437974048768.00 bird: 609025524604202146332672.00 sofa: 154112494701475012804608.00 pottedplant: 431129015867425278656512.00 pottedplant: 528759201511067497791488.00 chair: 864404411288458316742656.00 car: 295584159868056951062528.00 boat: 409424836197637156765696.00 bird: 387137890736067292692480.00 boat: 413303336196728627920896.00 boat: 1254042232163280462282752.00 diningtable: 67905689512658056773632.00 diningtable: 55461725828276228718592.00 person: 1285348086238622481645568.00 person: 877676771591898301202432.00 diningtable: 422349338465859044114432.00 diningtable: 1035021589817929666396160.00 person: 294653680156245187624960.00 horse: 34801903890477560627200.00 pottedplant: 729537671292182419472384.00 pottedplant: 85506558497155627089920.00 horse: 423965121925768521187328.00 sheep: 381308611522384017489920.00 car: 285574891681827514220544.00 car: 312031647980785682612224.00 motorbike: 1395278287011756885671936.00 boat: 368029730006683600551936.00 bicycle: 551794068769954034876416.00 bicycle: 649359258463774043013120.00 sheep: 467797251975881819160576.00 sheep: 330049253053202354405376.00 sofa: 124566142957351117783040.00 horse: 404276609334003357450240.00 tvmonitor: 556435694718704181837824.00 cat: 658793615135971871817728.00 car: 1099899725473888652492800.00 car: 286490995903628711034880.00 pottedplant: 669958074641020350365696.00 pottedplant: 208244879516941410107392.00 bird: 88956910286872239931392.00 bird: 7278842692645855166464.00 horse: 139100204710797456179200.00 tvmonitor: 126975586772392842625024.00 pottedplant: 346132508042467869720576.00 pottedplant: 737534767193699737665536.00 pottedplant: 358233608183618354544640.00 pottedplant: 324710073565368046059520.00 person: 346569285148728769904640.00 person: 338994662921055823200256.00 car: 320445272804639243239424.00 horse: 190436385582422805184512.00 horse: 290082346390479039365120.00 diningtable: 886842425495928696733696.00 train: 355843854106147493511168.00 train: 862657519036196829790208.00 car: 16835323475939089711104.00 bus: 659617521666201539837952.00 bus: 390311127033512544174080.00 chair: 373813396763340867371008.00 diningtable: 856268964806388176912384.00 sofa: 46960537516867703537664.00 boat: 993536447663225719226368.00 tvmonitor: 574150874068943670083584.00 horse: 125317082166418129027072.00 pottedplant: 216420588179680242171904.00 car: 299512775923801801097216.00 train: 589158525352005035098112.00 horse: 398525332465866139238400.00 cat: 405370767870672274194432.00 aeroplane: 181661391924469035958272.00 aeroplane: 71375609442755594420224.00 pottedplant: 7490318220348291547136.00 pottedplant: 1706988486065539371761664.00 boat: 360795651968433901273088.00 motorbike: 305618774312989229056000.00 chair: 565655788135030231924736.00 sheep: 276001878184302202585088.00 tvmonitor: 644135010838430229725184.00 person: 271285168222564534714368.00 sofa: 226644443880954628407296.00 bottle: 45975879501538673033216.00 sheep: 174577626027382454353920.00 horse: 70618617395789397229568.00 diningtable: 560641804569089092354048.00 aeroplane: 564308851558476263981056.00 chair: 734441622912027643084800.00 chair: 296516855350885380784128.00 person: 432222597943341891977216.00 person: 37792879511003128135680.00 cat: 395203909726281888956416.00 sofa: 1139037519445213059219456.00 horse: 262449267883250206900224.00 pottedplant: 623584329134001258233856.00 tvmonitor: 329701070758811086618624.00 person: 102310020131630977384448.00 cat: 101178328595667554926592.00 cat: 291584963398951950614528.00

FPS:0 Objects:

sofa: 435333180162771165118464.00 sofa: 66501539206437974048768.00 bird: 609025524604202146332672.00 sofa: 154112494701475012804608.00 pottedplant: 431129015867425278656512.00 pottedplant: 528759201511067497791 ...... and when i remove these program comments, like this: void cameraCallback(const sensor_msgs::ImageConstPtr& msg) { std::cout << "usb image received" << std::endl; cv_bridge::CvImagePtr cam_image; //cam_image_copy = cv::imread("/home/robot/Pictures/tar_test.jpeg", 1 ); //ROS_INFO("IMAGE READED");

  try
  {
     cam_image = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::BGR8);
  }
  catch (cv_bridge::Exception& e)
  {
     ROS_ERROR("cv_bridge exception: %s", e.what());
     return;
  }

  if (cam_image)
  {
     cam_image_copy = cam_image->image.clone();
     demo_yolo();
  }
  return;

}

it will also show "Segmentation fault (core dumped)", i guess the image capture program may be some problem, but i can capture images by myself, so can you give me some help about the result problem when i give the net a specified image. thank you very much.

pgigioli commented 6 years ago

Can you try re-cloning the repo? I've updated darknet_ros to version 2 and i've also included a dockerfile. The readme has instructions for using the dockerfile and it should allow you to use darknet_ros without any issues. Let me know if that works for you.

HankerSia commented 6 years ago

thank you very much, the darknet_ros package have been tested successfully, and i did not use the docker file. thank you again!