{"slug": "clap-model-crash-after-several-inference-iterations", "title": "CLAP model crash after several inference iterations", "summary": "A CLAP model that fails after roughly 150–300 inference slices and stays dead until a full PC restart is likely suffering from per-iteration memory growth rather than a model defect, since re-creating the model every 50 slices does not help. The proposed diagnostic runs three configurations — the original code, inference under torch.inference_mode() storing only plain floats, and that plus a forced allocator release every 50 slices via garbage collection and malloc_trim through ctypes or a worker process per batch — while logging resident memory every 10 slices. A flat memory slope in the second run indicates tensor retention, a flat slope only in the third indicates allocator growth, and identical climbing slopes in all three point to a bug inside the processor worth reporting upstream.", "body_md": "This one never got an answer, and the shape of it — fine for roughly 150–300 slices, dead until a full PC restart, and re-creating the model every 50 slices does not help — points away from the model and toward things that grow per iteration. Three suspects, all visible from here:\n\nRe-initializing the model cannot fix any of the three, which fits what you saw.\n\nThe check that separates them: log resident memory every 10 slices across three runs. Run A, your code as-is. Run B, inference under torch.inference_mode() storing only plain floats. Run C, B plus a forced allocator release every 50 slices (on CPU, garbage collection plus malloc_trim through ctypes, or simply a worker process per batch).\n\nIf B runs flat, it was retention. If B climbs but C is flat, it was the allocator. If all three climb at the same slope, the growth is inside the processor and you have a much rarer bug worth reporting upstream.\n\nOnce the slope is flat, batching becomes safe: fixed-size batches with a memory ceiling set from the measured slope, and this class of crash is simply gone.", "url": "https://wpnews.pro/news/clap-model-crash-after-several-inference-iterations", "canonical_source": "https://discuss.huggingface.co/t/clap-model-crash-after-several-inference-iterations/60630#post_2", "published_at": "2026-11-15 02:37:11+00:00", "updated_at": "2026-11-15 02:51:41.873354+00:00", "lang": "en", "topics": ["machine-learning", "ai-tools"], "entities": ["CLAP", "PyTorch", "torch.inference_mode()", "malloc_trim"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/clap-model-crash-after-several-inference-iterations", "markdown": "https://wpnews.pro/news/clap-model-crash-after-several-inference-iterations.md", "text": "https://wpnews.pro/news/clap-model-crash-after-several-inference-iterations.txt", "jsonld": "https://wpnews.pro/news/clap-model-crash-after-several-inference-iterations.jsonld"}}