GPU memory leaks and keeps increasing until I get RuntimeError: CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 31.75 GiB total capacity; 28.41 GiB already allocated; 4.00 MiB free; 30.51 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
I have a function to normalize pointsets. The leak is happening due to this function
def normalize_pointset(x):
"""x has shape B,3or4,N"""
if x.shape[1] == 4:
points = x[:,:3,:] / x[:,3,:].unsqueeze(1)+1e-7
else:
points = x
del(x)
points -= points.mean(dim=-1).unsqueeze(-1) # center to origin
points /= (points[:,0,:]**2+points[:,1,:]**2+points[:,2,:]**2).max(dim=1).values.view(-1,1,1) # max length=1
return points