KNN_CUDA icon indicating copy to clipboard operation
KNN_CUDA copied to clipboard

RuntimeError: CUDA out of memory.

Open Nireil opened this issue 2 years ago • 3 comments

when the points number is more than 50000, the OOM error appears. My GPU memory i s 10.92GiB, is there any way to reduce the memory occupy?

Nireil avatar May 28 '22 10:05 Nireil

It seems that memory leak exists in this code

Nireil avatar May 28 '22 11:05 Nireil

I have the same issue, but it may not be caused by a memory leak.

My code is:

dim = 3

num_p = 80000
num_q = 80000

ref = torch.randn((1, num_p, dim)).float().cuda()
query = torch.randn((1, num_q, dim)).float().cuda()

start_time = time.time()
knn = KNN(1, transpose_mode=True)
d, i = knn(ref, query)
print("query time:", time.time()-start_time)

print("d shape:", d.shape)
print("i shape:", i.shape)

I think this repo computes the distance matrix directly(?), so 80000x80000 cannot be allocated on the GPU. Roughly, assuming each element in the matrix takes one byte, this matrix requires (80000x80000)/(1024*1024*1024) ~ 5.9GB.

ShaoxiongYao avatar Nov 30 '22 23:11 ShaoxiongYao

@ShaoxiongYao did you find a fix or replacement for this issue?

JayKarhade avatar Oct 16 '23 02:10 JayKarhade