0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【pytorch】GPU メモリのアロケーションの謎

Posted at

同じFunctionを複数回呼ぶことによってGPUメモリの増加量が予想してたのと違かったからメモしておく

1回call

    def forward(self, left, right):

        left_feature     = self.feature_extraction(left)
        right_feature  = self.feature_extraction(right)
 
        #matching
        cost_left = self.create_costvolume(left_feature,right_feature)#batch,channel,disparity,height,width
        pred_left = self.estimate_disparity(cost_left,left.size()[2],left.size()[3])
        
        return pred_left,pred_left

image.png

2回call

``` def forward(self, left, right):
    left_feature     = self.feature_extraction(left)
    right_feature  = self.feature_extraction(right)

    #matching
    cost_left = self.create_costvolume(left_feature,right_feature)#batch,channel,disparity,height,width
    pred_left = self.estimate_disparity(cost_left,left.size()[2],left.size()[3])
   
    pred_left = self.estimate_disparity(cost_left,left.size()[2],left.size()[3])

    return pred_left,pred_left

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/482094/f29fc937-dde7-b57c-c3d6-51358eb1ccee.png)




<h2>3回call</h2>
def forward(self, left, right):

    left_feature     = self.feature_extraction(left)
    right_feature  = self.feature_extraction(right)

    #matching
    cost_left = self.create_costvolume(left_feature,right_feature)#batch,channel,disparity,height,width
    pred_left = self.estimate_disparity(cost_left,left.size()[2],left.size()[3])
    
    pred_left = self.estimate_disparity(cost_left,left.size()[2],left.size()[3])
    pred_left = self.estimate_disparity(cost_left,left.size()[2],left.size()[3])
   

    return pred_left,pred_left

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/482094/63616c27-56f8-2543-cc60-f4d924f52621.png)



<h2>4回call</h2>
def forward(self, left, right):

    left_feature     = self.feature_extraction(left)
    right_feature  = self.feature_extraction(right)

    #matching
    cost_left = self.create_costvolume(left_feature,right_feature)#batch,channel,disparity,height,width
    pred_left = self.estimate_disparity(cost_left,left.size()[2],left.size()[3])
    
    pred_left = self.estimate_disparity(cost_left,left.size()[2],left.size()[3])
    pred_left = self.estimate_disparity(cost_left,left.size()[2],left.size()[3])
    pred_left = self.estimate_disparity(cost_left,left.size()[2],left.size()[3])       

    return pred_left,pred_left
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/482094/de5ec79d-d2f7-682d-b4ba-fea7705c1881.png)


<h1>結論</h1>
2回callするまではメモリは増えるが3回目以降増えなくなった理由について、わかる人いたら教えてください
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?