cuda_streams
SKILL.md
cuda_streams
CUDA Streams permiten ejecutar múltiples operaciones GPU en paralelo (inferencia de modelos distintos, copia de datos y cómputo simultáneo), maximizando la utilización del hardware GPU.
When to use
Usar en el worker_pool_agent para ejecutar inferencias de múltiples modelos en paralelo en la misma GPU: face_match + liveness + deepfake detection simultáneamente.
Instructions
- Crear streams por modelo:
stream_liveness = torch.cuda.Stream() stream_facematch = torch.cuda.Stream() - Ejecutar inferencias en paralelo:
with torch.cuda.stream(stream_liveness): liveness_result = liveness_model(frame) with torch.cuda.stream(stream_facematch): facematch_result = facematch_model(face_crop) - Sincronizar streams:
torch.cuda.synchronize(). - Usar
torch.cuda.Eventpara timing preciso de cada modelo. - Monitorizar VRAM:
torch.cuda.memory_allocated(). - Limitar número de streams activos según VRAM disponible.
Notes
- Los streams solo paralelizzan si hay recursos GPU suficientes; en GPU pequeñas pueden serializar.
- No usar más de 4-8 streams simultáneos; más allá el overhead supera el beneficio.
- Triton Inference Server gestiona streams automáticamente; preferir Triton si está disponible.
Weekly Installs
5
Repository
davidcastagnetoa/skillsFirst Seen
13 days ago
Installed on
trae5
gemini-cli5
antigravity5
claude-code5
github-copilot5
codex5