Skip to content

Commit

Permalink
Check video memory to decide when to offload
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickvP committed Nov 1, 2024
1 parent f06f157 commit 51e7ee4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ def base_setup(
self.falcon_processor = ViTImageProcessor.from_pretrained(FALCON_MODEL_NAME)

# need > 48 GB of ram to store all models in VRAM
self.offload = "A40" in gpu_name
total_mem = torch.cuda.get_device_properties(0).total_memory
self.offload = total_mem < 48 * 1024**3
if self.offload:
print("GPU memory is:", total_mem / 1024 ** 3, ", offloading models")

device = "cuda"
max_length = 256 if self.flow_model_name == "flux-schnell" else 512
Expand Down

0 comments on commit 51e7ee4

Please sign in to comment.