Scalsol / mega.pytorch

Memory Enhanced Global-Local Aggregation for Video Object Detection, CVPR2020
Other
566 stars 115 forks source link

RuntimeError: CUDA out of memory. #101

Closed Flyingdog-Huang closed 3 years ago

Flyingdog-Huang commented 3 years ago

python demo/demo.py mega configs/MEGA/vid_R_101_C4_MEGA_1x.yaml configs/MEGA/MEGA_R_101.pth --video --visualize-path datasets/vid/1.mp4 --output-folder visualization/1_MEGA 1%|▉ | 23/1798 [00:23<30:20, 1.03s/it] Traceback (most recent call last): File "demo/demo.py", line 69, in visualization_results = vid_demo.run_on_video(args.visualize_path) File "/home/hlx/objectDetection/ht/project/mega.pytorch/demo/predictor.py", line 497, in run_on_video results = self.run_on_image_folder(tmpdir, suffix='.jpg') File "/home/hlx/objectDetection/ht/project/mega.pytorch/demo/predictor.py", line 484, in run_on_image_folder image_with_boxes = self.run_on_image(original_image, infos) File "/home/hlx/objectDetection/ht/project/mega.pytorch/demo/predictor.py", line 511, in run_on_image predictions = self.compute_prediction(image, infos) File "/home/hlx/objectDetection/ht/project/mega.pytorch/demo/predictor.py", line 531, in compute_prediction predictions = self.model(infos) File "/home/hlx/anaconda3/envs/MEGA/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in call result = self.forward(*input, kwargs) File "/home/hlx/objectDetection/ht/project/mega.pytorch/mega_core/modeling/detector/generalized_rcnn_mega.py", line 78, in forward return self._forward_test(images["cur"], infos) File "/home/hlx/objectDetection/ht/project/mega.pytorch/mega_core/modeling/detector/generalized_rcnn_mega.py", line 221, in _forward_test x, result, detector_losses = self.roi_heads(feats, proposals_list, None) File "/home/hlx/anaconda3/envs/MEGA/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in call result = self.forward(*input, *kwargs) File "/home/hlx/objectDetection/ht/project/mega.pytorch/mega_core/modeling/roi_heads/roi_heads.py", line 26, in forward x, detections, loss_box = self.box(features, proposals, targets) File "/home/hlx/anaconda3/envs/MEGA/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in call result = self.forward(input, kwargs) File "/home/hlx/objectDetection/ht/project/mega.pytorch/mega_core/modeling/roi_heads/box_head/box_head.py", line 96, in forward x = self.feature_extractor(features, proposals) File "/home/hlx/anaconda3/envs/MEGA/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in call result = self.forward(*input, **kwargs) File "/home/hlx/objectDetection/ht/project/mega.pytorch/mega_core/modeling/roi_heads/box_head/roi_box_feature_extractors.py", line 655, in forward return self._forward_test(x, proposals) File "/home/hlx/objectDetection/ht/project/mega.pytorch/mega_core/modeling/roi_heads/box_head/roi_box_feature_extractors.py", line 919, in _forward_test feat_cur = self._forward_test_single(i, self.local_cache[i], memory) File "/home/hlx/objectDetection/ht/project/mega.pytorch/mega_core/modeling/roi_heads/box_head/roi_box_feature_extractors.py", line 817, in _forward_test_single position_embedding = self.cal_position_embedding(rois_cur, rois_ref) File "/home/hlx/objectDetection/ht/project/mega.pytorch/mega_core/modeling/roi_heads/box_head/roi_box_feature_extractors.py", line 244, in cal_position_embedding position_embedding = self.extract_position_embedding(position_matrix, feat_dim=64) File "/home/hlx/objectDetection/ht/project/mega.pytorch/mega_core/modeling/roi_heads/box_head/roi_box_feature_extractors.py", line 140, in extract_position_embedding embedding = torch.cat([sin_mat, cos_mat], dim=3) RuntimeError: CUDA out of memory. Tried to allocate 594.00 MiB (GPU 0; 4.94 GiB total capacity; 2.43 GiB already allocated; 586.25 MiB free; 936.28 MiB cached)

有老哥遇到类似的问题了吗

Flyingdog-Huang commented 3 years ago

原因找到了,我的显存太小 解决办法,1、减少数据输入数量或尺寸,2、换用MEGA_R_50模型