I’m trying to convert a model that works on pytorch 0.3 to 0.4.1. However it seems to be taking up lots of memory both during training and evaluation in 0.4.1.
This is the code:

  
      github.com
  
  
    multimodallearning/pytorch-mask-rcnn/blob/master/model.py 1
"""
Mask R-CNN
The main Mask R-CNN model implemenetation.

Copyright (c) 2017 Matterport, Inc.
Licensed under the MIT License (see LICENSE for details)
Written by Waleed Abdulla
"""

import datetime
import math
import os
import random
import re

import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim


  This file has been truncated. show original

  
  
    
    
  
  


As I step through the code at around line 1636, memory usage surges:
    [p2_out, p3_out, p4_out, p5_out, p6_out] = self.fpn(molded_images)

    # Note that P6 is used in RPN, but not in the classifier heads.
    rpn_feature_maps = [p2_out, p3_out, p4_out, p5_out, p6_out]
    mrcnn_feature_maps = [p2_out, p3_out, p4_out, p5_out]

For pytorch 0.4 I’ve replaced “F.upsample()” with “F.interpolate()”. Does anyone know the cause of this memory usage surge?