debug: Force re-clone + detailed memory logging
Browse files49 unmodified lines505152535455147 unmodified lines2032042052062072082092102112122132142152162172182192207 unmodified lines2282292302312322333 unmodified lines23723823924024124249 unmodified lines"""Clone and setup PuLID repository."""pulid_dir = "/tmp/PuLID"if not os.path.exists(pulid_dir):print("[FLUX-Dev] Cloning PuLID repository...")import subprocess147 unmodified lineselse:self._setup_diffusers_pipeline()def _setup_pulid_generator(self):"""Setup PuLID FluxGenerator."""print("[FLUX-Dev] Setting up PuLID generator...")load_start = time.time()# Clone and import PuLIDpulid_dir = setup_pulid()# Import PuLID componentsfrom app_flux import FluxGeneratorimport argparse# Create args namespace for FluxGeneratorargs = argparse.Namespace(version=PULID_VERSION,7 unmodified linesdev=False,)# Initialize generatorself._generator = FluxGenerator(model_name="flux-dev",3 unmodified linesargs=args)self._pulid_loaded = Trueprint(f"[FLUX-Dev] PuLID generator ready in {time.time() - load_start:.1f}s")49 unmodified lines50515253545556575859606162147 unmodified lines2102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512527 unmodified lines2602612622632642652662673 unmodified lines27127227327427527627727849 unmodified lines"""Clone and setup PuLID repository."""pulid_dir = "/tmp/PuLID"# ALWAYS delete and re-clone to ensure patches are applied fresh# This prevents issues with cached/stale code from previous deploymentsif os.path.exists(pulid_dir):import shutilprint("[FLUX-Dev] Removing existing PuLID directory to apply fresh patches...")shutil.rmtree(pulid_dir)if not os.path.exists(pulid_dir):print("[FLUX-Dev] Cloning PuLID repository...")import subprocess147 unmodified lineselse:self._setup_diffusers_pipeline()def _log_gpu_memory(self, stage: str):"""Log GPU memory usage at a specific stage."""if torch.cuda.is_available():allocated = torch.cuda.memory_allocated() / 1e9reserved = torch.cuda.memory_reserved() / 1e9print(f"[FLUX-Dev] GPU Memory @ {stage}: allocated={allocated:.2f}GB, reserved={reserved:.2f}GB")def _setup_pulid_generator(self):"""Setup PuLID FluxGenerator."""print("[FLUX-Dev] Setting up PuLID generator...")load_start = time.time()self._log_gpu_memory("before_setup_pulid")# Clone and import PuLIDpulid_dir = setup_pulid()self._log_gpu_memory("after_setup_pulid")# Verify patches were appliedutil_path = os.path.join(pulid_dir, "flux", "util.py")app_flux_path = os.path.join(pulid_dir, "app_flux.py")with open(util_path, "r") as f:util_content = f.read()with open(app_flux_path, "r") as f:app_content = f.read()print(f"[FLUX-Dev] util.py patched: {'PATCHED: respect device param' in util_content}")print(f"[FLUX-Dev] app_flux.py patched: {'PATCHED: T5/CLIP offload' in app_content}")# Import PuLID componentsfrom app_flux import FluxGeneratorimport argparseself._log_gpu_memory("after_import")# Create args namespace for FluxGeneratorargs = argparse.Namespace(version=PULID_VERSION,7 unmodified linesdev=False,)print(f"[FLUX-Dev] Initializing FluxGenerator with offload={self.use_offload}, aggressive={self.use_aggressive_offload}")# Initialize generatorself._generator = FluxGenerator(model_name="flux-dev",3 unmodified linesargs=args)self._log_gpu_memory("after_FluxGenerator_init")self._pulid_loaded = Trueprint(f"[FLUX-Dev] PuLID generator ready in {time.time() - load_start:.1f}s")
handler.py+36