question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

problem with RAM allocating in FasterRCNN

See original GitHub issue

Hello. First of all I’d like to thank for adding object detection models to torchvision, it’s a great help for the community.

However, I encountered a problem while trying to use them. I just copied the example code from https://github.com/pytorch/vision/blob/3d5610391eaef38ae802ffe8b693ac17b13bd5d1/torchvision/models/detection/faster_rcnn.py#L102-L140 to a jupyter notebook and realized that during each execution of model(x) (on CPU) more than 2 GB of RAM is grabbed and not released afterwards. Running del model does not release RAM, only restarting the kernel does.

I met the same problem for the model defined in the following way:

model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True)
in_features = model.roi_heads.box_predictor.cls_score.in_features
model.roi_heads.box_predictor = FastRCNNPredictor(in_features, num_classes)

as stated in https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html

What to do to get rid of this problem? Thanks in advance.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:22 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
fmassacommented, Jun 4, 2019

@buus2 this is not a leak, and you shouldn’t face OOM errors because of that.

As workarounds, use torch.no_grad(), and maybe use jemalloc when running your programs.

1reaction
buus2commented, Jun 3, 2019

@fmassa you are right, with no_grad RAM does not clog. Could you please suggest a workaround for forwardpropagation during training?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Out of memory error with py-faster-rcnn
I noticed that the GPU memory used by training incremented and decremented by around 18MB consistently all the time. If my adversary CUDA ......
Read more >
Faster rcnn memory consumption - Jetson Xavier NX
I tried JetPack 4.4 on Xavier NX as well, which has a much worse result the all memory has been totally consumed. Could...
Read more >
Why do I run into 'Out of memory' error using Faster R-CNN ...
I am trying to use the fasterRCNNobjectDetector, but it keeps getting "out of memory" errors even when lowering the miniBatchSize to 4 (which...
Read more >
faster rcnn running on gpu - out of memory
I use this faster rcnn: https://github.com/lev-kusanagi/Faster-RCNN_TF ... (GPU_0_bfc) ran out of memory trying to allocate 3.23GiB.
Read more >
Memory Error : FPN+FasterRCNN in parallel - vision
... into memory error while trying to re-train an FPN+FasterRCNN network in ... Tried to allocate 8.51 GiB (GPU 0; 10.73 GiB total...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found