Spaces:
Sleeping
Sleeping
Minor memory tweaks
Browse files- model_setup.py +6 -1
model_setup.py
CHANGED
|
@@ -2,10 +2,11 @@
|
|
| 2 |
"""loading the models to be used by the Mulltimodal RAG system."""
|
| 3 |
|
| 4 |
import torch
|
|
|
|
| 5 |
|
| 6 |
from sentence_transformers import SentenceTransformer
|
| 7 |
from transformers import AutoProcessor, Gemma3ForConditionalGeneration, BitsAndBytesConfig
|
| 8 |
-
|
| 9 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 10 |
|
| 11 |
# Embedding model
|
|
@@ -33,3 +34,7 @@ model.eval()
|
|
| 33 |
|
| 34 |
# Processor
|
| 35 |
processor = AutoProcessor.from_pretrained(model_name, use_fast=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
"""loading the models to be used by the Mulltimodal RAG system."""
|
| 3 |
|
| 4 |
import torch
|
| 5 |
+
import gc
|
| 6 |
|
| 7 |
from sentence_transformers import SentenceTransformer
|
| 8 |
from transformers import AutoProcessor, Gemma3ForConditionalGeneration, BitsAndBytesConfig
|
| 9 |
+
from utils import clear_gpu_cache
|
| 10 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 11 |
|
| 12 |
# Embedding model
|
|
|
|
| 34 |
|
| 35 |
# Processor
|
| 36 |
processor = AutoProcessor.from_pretrained(model_name, use_fast=True)
|
| 37 |
+
|
| 38 |
+
# Free memory
|
| 39 |
+
clear_gpu_cache()
|
| 40 |
+
gc.collect()
|