# How to fix memory issue when I use += operator

**URL:** <https://discuss.pytorch.org/t/how-to-fix-memory-issue-when-i-use-operator/39331>\
**Category:** autograd\
**Created:** [March 9, 2019, 4:36am UTC](https://discuss.pytorch.org/t/how-to-fix-memory-issue-when-i-use-operator/39331 "2019-03-09T04:36:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![youngminpark2559](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/y/7c8e57/32.png) [@youngminpark2559](https://discuss.pytorch.org/u/youngminpark2559)\
**Post date:** [March 9, 2019, 4:36am UTC](https://discuss.pytorch.org/t/how-to-fix-memory-issue-when-i-use-operator/39331/1 "2019-03-09T04:36:12Z")

</div>

I’m testing following code which uses += operator

Accumulates loss  
@ [https://github.com/lixx2938/CGIntrinsics/blob/master/models/networks.py#L790](https://github.com/lixx2938/CGIntrinsics/blob/master/models/networks.py#L790)

Gets final loss and I update network using that summed final loss  
@ [https://github.com/lixx2938/CGIntrinsics/blob/master/models/networks.py#L835](https://github.com/lixx2938/CGIntrinsics/blob/master/models/networks.py#L835)

* * *

I’ve read this relevant link  
@ [https://discuss.pytorch.org/t/cuda-memory-continuously-increases-when-net-images-called-in-every-iteration](https://discuss.pytorch.org/t/cuda-memory-continuously-increases-when-net-images-called-in-every-iteration)

* * *

Above code (from CGIntrinsics project) has no problem about GPU memory issue (like continuously growing gradient graph)?  
Because I’m continuously running into `RuntimeError: CUDA error: out of memory`
