unslothai/unsloth · error · HTTPException
Memory cleanup failed. See server logs for details.
Error message
Memory cleanup failed. See server logs for details.
What it means
HTTP 500 raised when ExportBackend.cleanup_memory completes but returns success=False — the backend ran, decided it could not free resources, and reported failure. The detail points to server logs because the reason (e.g. a worker refusing to release a model) is logged by the backend, not returned.
Source
Thrown at studio/backend/routes/export.py:131
if isinstance(e, SidecarSwapInProgress):
# Expected loss of the race against a sidecar install: retryable 409.
raise HTTPException(status_code = 409, detail = str(e))
logger.error(f"Error loading checkpoint: {e}", exc_info = True)
raise HTTPException(
status_code = 500,
detail = "Failed to load checkpoint",
)
@router.post("/cleanup", response_model = ExportOperationResponse)
async def cleanup_export_memory(current_subject: str = Depends(get_current_subject)):
"""Cleanup export-related models from memory (ExportBackend.cleanup_memory)."""
try:
backend = get_export_backend()
success = await asyncio.to_thread(backend.cleanup_memory)
if not success:
raise HTTPException(
status_code = 500,
detail = "Memory cleanup failed. See server logs for details.",
)
return ExportOperationResponse(
success = True,
message = "Memory cleanup completed successfully",
)
except HTTPException:
raise
except Exception as e:
logger.error(f"Error during export memory cleanup: {e}", exc_info = True)
raise HTTPException(
status_code = 500,
detail = "Failed to cleanup export memory",
)
View on GitHub (pinned to 203007d190)
Solutions
- Check server logs around the cleanup call for the backend's reason.
- Cancel any active export first (POST /export/cancel), then retry cleanup.
- If a worker subprocess is stuck, restart the backend process to force-release VRAM.
Defensive patterns
Strategy: try-catch
Validate before calling
const st = await api.get('/export/status');
if (st.is_export_active) await api.post('/export/cancel'); Try / catch
try {
await api.post('/export/cleanup');
} catch (e) {
if (e.status === 500) log('cleanup refused; check server logs');
} Prevention
- Cancel active exports before cleanup.
- Treat cleanup failure as non-fatal; it rarely blocks the next load.
When it happens
Trigger: POST /export/cleanup while a model is pinned by an active export/training subprocess, or when the cleanup routine internally catches an error and returns False instead of raising.
Common situations: Trying to free memory mid-export; a stuck worker subprocess holding references; platform differences in the cleanup path.
Related errors
- Failed to cleanup export memory
- Failed to load checkpoint
- Failed to cancel export
- Failed to get export status
- Failed to get export logs
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/6268ec00f84a2235.
Report an issue: GitHub.