kkytai commited on
Commit ·
da45f94
1
Parent(s): 65a4b73
fix: Enable CPU offload for A100 80GB to prevent OOM
Browse files- Change offload threshold from 70GB to 85GB (includes A100 80GB)
- Add memory cleanup after model initialization
- Issue: Models consumed ~77GB leaving no room for inference
116 unmodified lines11711811912012112212312447 unmodified lines172173174175176177116 unmodified linesprint(f"[FLUX-Dev] ENABLE_OFFLOAD: {ENABLE_OFFLOAD}")# Determine offload mode based on GPU memoryif ENABLE_OFFLOAD == "auto":self.use_offload = self.gpu_memory_gb < 70self.use_aggressive_offload = self.gpu_memory_gb < 50elif ENABLE_OFFLOAD == "true":self.use_offload = True47 unmodified linesself._pulid_loaded = Trueprint(f"[FLUX-Dev] PuLID generator ready in {time.time() - load_start:.1f}s")def _setup_diffusers_pipeline(self):"""Fallback: Setup diffusers FluxPipeline without PuLID."""print("[FLUX-Dev] Setting up diffusers pipeline (no PuLID)...")116 unmodified lines11711811912012112212312412547 unmodified lines173174175176177178179180181182183184185116 unmodified linesprint(f"[FLUX-Dev] ENABLE_OFFLOAD: {ENABLE_OFFLOAD}")# Determine offload mode based on GPU memory# A100 80GB also needs offload - models consume ~77GB leaving no room for inferenceif ENABLE_OFFLOAD == "auto":self.use_offload = self.gpu_memory_gb < 85 # Enable for A100 80GB tooself.use_aggressive_offload = self.gpu_memory_gb < 50elif ENABLE_OFFLOAD == "true":self.use_offload = True47 unmodified linesself._pulid_loaded = Trueprint(f"[FLUX-Dev] PuLID generator ready in {time.time() - load_start:.1f}s")# Clean up memory after model loading to free any temporary allocationsgc.collect()torch.cuda.empty_cache()allocated = torch.cuda.memory_allocated() / 1e9reserved = torch.cuda.memory_reserved() / 1e9print(f"[FLUX-Dev] Post-init memory: allocated={allocated:.2f}GB, reserved={reserved:.2f}GB")def _setup_diffusers_pipeline(self):"""Fallback: Setup diffusers FluxPipeline without PuLID."""print("[FLUX-Dev] Setting up diffusers pipeline (no PuLID)...")
handler.py+9-1