spmallick / learnopencv

Learn OpenCV : C++ and Python Examples
https://www.learnopencv.com/
20.95k stars 11.56k forks source link

RuntimeError: CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 2.00 GiB total capacity; 1.26 GiB already allocated; 9.93 MiB free; 1.33 GiB reserved in total by PyTorch) #382

Open sharqawiDev opened 4 years ago

sharqawiDev commented 4 years ago

I try to use Background-Removal.py from app-seperation-semseg/ to remove the background from some images on my device, but I always get this error: 1

My specs:

I found this replay on someone having the same issue:

https://github.com/pytorch/pytorch/issues/16417#issuecomment-497952224

but I don't know how to decrease the batch size.

I appreciate any help.

BT-julio commented 4 years ago

j'ai le même problème mais je ne sais pas encore comment le resourdre Epoch gpu_mem GIoU obj cls total targets img_size 0% 0/32 [00:00<?, ?it/s]/usr/local/lib/python3.6/dist-packages/torch/cuda/memory.py:346: FutureWarning: torch.cuda.memory_cached has been renamed to torch.cuda.memory_reserved FutureWarning) 0/299 13.3G 4.74 4.03 0 8.78 24 576: 62% 20/32 [00:37<00:16, 1.39s/it]Traceback (most recent call last): File "train.py", line 414, in train(hyp) # train normally File "train.py", line 264, in train pred = model(imgs) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 722, in _call_impl result = self.forward(*input, kwargs) File "/content/drive/My Drive/2020_Julio_Yolo_projet/yolov3/models.py", line 238, in forward return self.forward_once(x) File "/content/drive/My Drive/2020_Julio_Yolo_projet/yolov3/models.py", line 292, in forward_once x = module(x) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 722, in _call_impl result = self.forward(*input, *kwargs) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/container.py", line 117, in forward input = module(input) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 722, in _call_impl result = self.forward(input, kwargs) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/conv.py", line 419, in forward return self._conv_forward(input, self.weight) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/conv.py", line 416, in _conv_forward self.padding, self.dilation, self.groups) RuntimeError: CUDA out of memory. Tried to allocate 50.00 MiB (GPU 0; 14.73 GiB total capacity; 13.57 GiB already allocated; 17.88 MiB free; 13.72 GiB reserved in total by PyTorch) 0/299 13.3G 4.74 4.03 0 8.78 24 576: 62% 20/32 [00:40<00:24, 2.01s/it]

pasquale90 commented 2 years ago

My problem solved by reducing the size of the input video..