Pytorch release memory problem

Hi,
I have tried the follow code on PC platform, it can release memory successfully, but it doesn’t work on TX2 (Jetpack 4.4) .
Is there other method to release memory with Pytorch object?

import gc
import torch
x=torch.randn((32,3,300,300),device=torch.device(‘cuda’))
del x
gc.collect()
torch.cuda.empty_cache()

Hi,

Could you share which PyTorch package do you use?
Do you install it from the link shared in this topic?

Thanks.

Hi AastaLLL,
Sorry, I forgot to mention my pytorch version.
My pytorch version is 1.6 (torch-1.6.0-cp36-cp36m-linux_aarch64.whl ), and it was installed from Jetson Zoo.

Hi AastaLLL,
It can release memory successfully on TX2, with both pytorch 1.6 and 1.7.
Tensor shape like (32,3,300,300) is too small, can not get the obvious memory release amount.
So when I increase shape to (2000,3,300,300), I see the memory release result.

Thank you for help.