[Bug]: Memory leakage during image feature extraction(OOM)
youwenwang2024 opened this issue · 2 comments
youwenwang2024 commented
def pipline(img):
p_search = (
pipe.input('img')
.map('img', 'vec', ops.image_embedding.timm('lambda_resnet50ts'))
.output('vec')
)
res = pipline(img).get()
del p_search
return res
if __name__ =="__main__":
from glob import glob
path = 'mypath'
inputFiles = glob(path+"/*.*")
print(len(inputFiles))
for idx in range(len(inputFiles)):
input_file_path = inputFiles[idx]
pipline(input_file_path)
There are a large number of images in the folder. When calling the feature extraction interface in a loop, the memory gradually increases, ultimately leading to OOM. What is the reason for this
Environment
- Towhee version(1.1.0):
- OS(Ubuntu):
- GPU:4090
junjiejiangjjj commented
Don't create a new pipeline every time, try this:
p_search = (
pipe.input('img')
.map('img', 'vec', ops.image_embedding.timm('lambda_resnet50ts'))
.output('vec')
)
def pipline(img):
res = p_search(img).get()
return res
youwenwang2024 commented
According to the method you provided, the problem has been resolved. Thank you