Getting GPU device error when running the detection pipeline
Hi team,
I am trying to run the detection pipeline on my system.
The command i am entering is
- python3 sdk/ml/python_samples/detection_and_tracking_pipeline/detection_and_tracking_pipeline.py --object_detector_dir ~/Documents/pre-trained_models/metavision_sdk_3.x/red_event_cube_05_2020/ --record_file /media/e/dataset/data/raw/day/my_recording.raw --display --device gpu
The error i get is:
- Namespace(deletion_time=100000, detection_merge_weight=0.7, detector_NMS_IOU_threshold=None, detector_confidence_threshold=None, device='gpu', display=True, end_ts=9223372036854775807, iou_to_match_a_detection=0.2, max_duration=None, max_iou_for_one_det_to_many_tracks=0.5, max_iou_inter_track=0.5, network_input_height=None, network_input_width=None, noise_filtering_threshold=10000, noise_filtering_type='trail', number_of_consecutive_detections_to_create_a_new_track=1, object_detector_dir='/home/exx/Documents/pre-trained_models/metavision_sdk_3.x/red_event_cube_05_2020/', output_detections_filename=None, output_tracks_filename=None, output_video_filename=None, pipeline_delta_t=10000, record_file='/media/e/dataset/data/raw/day/my_recording.raw', start_ts=0, timesurface_delta_t=200000, update_tracklets_between_detections=True, use_descriptor=False)
- /home/exx/.local/lib/python3.8/site-packages/torch/nn/modules/module.py:1501: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3483.)
- return forward_call(*args, **kwargs)
- Traceback (most recent call last):
- File "sdk/ml/python_samples/detection_and_tracking_pipeline/detection_and_tracking_pipeline.py", line 298, in <module>
- main()
- File "sdk/ml/python_samples/detection_and_tracking_pipeline/detection_and_tracking_pipeline.py", line 294, in main
- run(args)
- File "sdk/ml/python_samples/detection_and_tracking_pipeline/detection_and_tracking_pipeline.py", line 243, in run
- detections = object_detector.process(ts, frame_buffer)
- File "/usr/lib/python3/dist-packages/metavision_ml/detection_tracking/object_detector.py", line 124, in process
- tensorBoxList = self.model(frame_buffer_tensor, self.detection_threshold)
- File "/home/exx/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
- return forward_call(*args, **kwargs)
- RuntimeError: The following operation failed in the TorchScript interpreter.
- Traceback of TorchScript, serialized code (most recent call last):
- File "code/__torch__/metavision_ml/detection/jitting.py", line 16, in forward
- cls0 = (self.rpn).get_scores(cls, )
- anchors = (self.anchor_generator).forward(xs, x, )
- targets = (self.box_decoder).forward(anchors, loc, cls0, 0.10000000000000001, 0.20000000000000001, score_thresh, 0.5, torch.size(x, 1), )
- ~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
- return targets
- def forward_network_without_box_decoding(self: __torch__.metavision_ml.detection.jitting.SSD,
- File "code/__torch__/metavision_ml/detection/jitting.py", line 49, in forward
- _7 = torch.add(xy, torch.div(wh, 2), alpha=1)
- box_preds = torch.cat([_6, _7], torch.sub(torch.dim(xy), 1))
- _8 = (self)._box_filtering(box_preds, cls_preds, score_thresh, nms_thresh, )
- ~~~~~~~~~~~~~~~~~~~~ <--- HERE
- box_tensor, batch_index, = _8
- num_tbins = torch.floordiv(torch.len(cls_preds), batch_size)
- File "code/__torch__/metavision_ml/detection/jitting.py", line 80, in _box_filtering
- _19 = torch.expand(torch.unsqueeze(boxes, 2), [-1, num_anchors, num_classes, 4], implicit=False)
- boxes0 = torch.contiguous(_19, memory_format=0)
- _20 = (self)._score_filtering(scores0, score_thresh, )
- ~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
- scores1, score_indices, = _20
- _21 = torch.view(boxes0, [-1, 4])
- File "code/__torch__/metavision_ml/detection/jitting.py", line 117, in _score_filtering
- mask = torch.ge(scores2, score_threshold)
- _33 = annotate(List[Optional[Tensor]], [mask])
- score_indices0 = torch.contiguous(torch.index(score_indices, _33), memory_format=0)
- ~~~~~~~~~~~ <--- HERE
- _34 = annotate(List[Optional[Tensor]], [score_indices0])
- scores3 = torch.index(scores2, _34)
- Traceback of TorchScript, original code (most recent call last):
- File "/home/fmenasri/sources/metavision/sdk/modules/ml/python/metavision_ml/detection/jitting.py", line 60, in forward
- box_preds = torch.cat([xy - wh / 2, xy + wh / 2], xy.dim()-1)
- box_tensor, batch_index = self._box_filtering(box_preds, cls_preds, score_thresh, nms_thresh)
- ~~~~~~~~~~~~~~~~~~~ <--- HERE
- num_tbins = len(cls_preds) // batch_size
- File "/home/fmenasri/sources/metavision/sdk/modules/ml/python/metavision_ml/detection/jitting.py", line 83, in _box_filtering
- # filtering boxes by score
- boxes = boxes.unsqueeze(2).expand(-1, num_anchors, num_classes, 4).contiguous()
- scores, score_indices = self._score_filtering(scores, score_thresh)
- ~~~~~~~~~~~~~~~~~~~~~ <--- HERE
- boxes = boxes.view(-1, 4)[score_indices].contiguous()
- idxs = idxs.view(-1)[score_indices].contiguous()
- File "/home/fmenasri/sources/metavision/sdk/modules/ml/python/metavision_ml/detection/jitting.py", line 112, in _score_filtering
- score_indices = torch.arange(scores.shape[0])
- mask = scores >= score_threshold
- score_indices = score_indices[mask].contiguous()
- ~~~~~~~~~~~~~~~~~~~ <--- HERE
- scores = scores[score_indices]
- return scores, score_indices
- RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)
The pipeline works alright if I use cpu as the device, but not for gpu. Could you please help me with this.
Thanks.