Skip to content

Commit 412ed1f

Browse files
mitchellxhhlapp
andauthored
fix: release GPU tensors after prediction (#144)
--------- Co-authored-by: Hilmar Lapp <[email protected]>
1 parent a4b1eb7 commit 412ed1f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/bioclip/predict.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ def create_probabilities_for_images(self, images: List[str] | List[PIL.Image.Ima
278278
images = [self.ensure_rgb_image(image) for image in images]
279279
img_features = self.create_image_features(images)
280280
probs = self.create_probabilities(img_features, txt_features)
281+
# prevent accumulation of GPU VRAM
282+
probs = probs.detach().cpu()
281283
result = {}
282284
for i, key in enumerate(keys):
283285
result[key] = probs[i]

0 commit comments

Comments
 (0)