pytorch3d icon indicating copy to clipboard operation
pytorch3d copied to clipboard

Unexpected cuda allocate in the knn_points function

Open pengc02 opened this issue 10 months ago • 0 comments

Hi guys, I met a problem here:

import torch
from pytorch3d.ops import knn_points
import ipdb
points = torch.rand(1000, 3)
device = "cuda"

with torch.no_grad():
    fused_point_cloud = points.float().to(device)
    dist2 = torch.clamp_min(
        knn_points(fused_point_cloud[None], fused_point_cloud[None], K=4)[0][0, :, 1:].mean(-1),
        1e-7
    ).cpu().detach().clone()
    fused_point_cloud = fused_point_cloud.cpu().detach().clone()
    
ipdb.set_trace()

image

As i move all the variables to cpu, there should not be any cuda allocate, however there is still some cuda memory allocate when it runs to the 'ipdb.set_trace()'. I wonder if it's a bug or just i missused something.

pengc02 avatar Dec 08 '24 13:12 pengc02