chore: auto-commit (95 archivos)
- cmd/fn/doctor.go - cmd/fn/main.go - cpp/apps/primitives_gallery/playground/tables/CMakeLists.txt - cpp/apps/primitives_gallery/playground/tables/data_table.cpp - cpp/apps/primitives_gallery/playground/tables/data_table_logic.cpp - cpp/apps/primitives_gallery/playground/tables/data_table_logic.h - cpp/apps/primitives_gallery/playground/tables/self_test.cpp - cpp/apps/primitives_gallery/playground/tables/tql.cpp - cpp/apps/primitives_gallery/playground/tables/viz.cpp - cpp/apps/primitives_gallery/playground/tables/viz.h - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
---
|
||||
name: diffusers_unload
|
||||
kind: function
|
||||
lang: py
|
||||
domain: ml
|
||||
version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "def diffusers_unload(pipe: Any | None = None) -> None"
|
||||
description: "Libera la memoria de un pipeline diffusers. Si pipe=None limpia el cache global de diffusers_load_pipeline. Siempre llama gc.collect() y torch.cuda.empty_cache()."
|
||||
tags: [diffusers, ml, memory, cleanup, vram, cache]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: "error_go_core"
|
||||
imports: [torch, gc]
|
||||
params:
|
||||
- name: pipe
|
||||
desc: "Pipeline a liberar con del. Si None, limpia el cache global _PIPELINE_CACHE de diffusers_load_pipeline (descarga todos los pipelines cacheados)."
|
||||
output: "None. Efecto secundario: del pipe si pasado, cache limpiado si None, gc.collect() y torch.cuda.empty_cache() siempre."
|
||||
tested: true
|
||||
tests:
|
||||
- "unload None limpia cache cuda si disponible"
|
||||
test_file_path: "python/functions/ml/tests/test_diffusers_backend.py"
|
||||
file_path: "python/functions/ml/diffusers_unload.py"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```python
|
||||
from diffusers_unload import diffusers_unload
|
||||
|
||||
# Liberar un pipeline especifico
|
||||
diffusers_unload(pipe)
|
||||
|
||||
# Limpiar TODO el cache (descarga todos los modelos en memoria)
|
||||
diffusers_unload()
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
`del pipe` no garantiza liberacion inmediata si hay otras referencias al objeto.
|
||||
Llamar `diffusers_unload(pipe)` + borrar la referencia local (`pipe = None`)
|
||||
para asegurar que el GC pueda recolectar.
|
||||
|
||||
`torch.cuda.empty_cache()` solo libera cache del allocator de PyTorch, no
|
||||
memoria que otros procesos ocupen. Para liberacion total, el proceso debe terminar.
|
||||
|
||||
Import lazy de torch — si no esta instalado, omite empty_cache silenciosamente.
|
||||
Reference in New Issue
Block a user