NVIDIA / CUDALibrarySamples

CUDA Library Samples
Other
1.61k stars 344 forks source link

memory was not free. nvcomp python api #206

Open Eutenacity opened 3 months ago

Eutenacity commented 3 months ago

how to free gpu memory allocated by nvcomp? The code will allocate 24GB GPU memory and free until code end.

import numpy as np
from nvidia import nvcomp
import torch
import gc
alogs = ['lz4','ANS', "Cascaded"]
codec = nvcomp.Codec(algorithm=alogs[0])
data_gpu = torch.randn(4096*14336,dtype=torch.float16,device = "cuda:0")
nvarr_d = nvcomp.as_array(data_gpu)
com_arr = codec.encode(nvarr_d)
a = torch.tensor(com_arr.cpu(),dtype=torch.int8).cuda()
for i in range(32*8):

    b = nvcomp.as_array(a)
    dec_arr = codec.decode(b,data_type="<f2")

    del dec_arr

    torch.cuda.empty_cache()
    gc.collect()
naveenaero commented 3 months ago

Hi @Eutenacity Thank you for reporting this memory leak issue. We are actively working to fix this and will include the fix in the next release of nvCOMP.