Spaces:
Running on Zero
Running on Zero
File size: 1,525 Bytes
612669e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | """
Launch ComfyUI's main.py with PyTorch's cuDNN Scaled-Dot-Product-Attention
backend disabled. On H200 (ZeroGPU), cuDNN "frontend" attention can error with:
RuntimeError: cuDNN Frontend error: [cudnn_frontend] Error: No valid execution plans built.
in Anima's LLM/attention path (F.scaled_dot_product_attention). Flash / math SDPA
still work.
Set ANIMA_ALLOW_CUDNN_SDPA=1 in the environment to opt out and use PyTorch defaults.
"""
from __future__ import annotations
import os
import runpy
import sys
def main() -> None:
allow = os.environ.get("ANIMA_ALLOW_CUDNN_SDPA", "").strip() == "1"
if not allow:
os.environ.setdefault("TORCH_CUDNN_SDPA_ENABLED", "0")
root = os.environ.get("COMFYUI_ROOT", "").strip()
if not root:
print("comfy_entry: missing COMFYUI_ROOT", file=sys.stderr)
sys.exit(1)
main_py = os.path.join(root, "main.py")
if not os.path.isfile(main_py):
print(f"comfy_entry: not found: {main_py}", file=sys.stderr)
sys.exit(1)
if not allow:
import torch
if torch.cuda.is_available() and hasattr(
torch.backends.cuda, "enable_cudnn_sdp"
):
torch.backends.cuda.enable_cudnn_sdp(False)
os.chdir(root)
if root not in sys.path:
sys.path.insert(0, root)
# Same argv shape as: python main.py [args...]
sys.argv = [main_py, *sys.argv[1:]]
runpy.run_path(main_py, run_name="__main__")
if __name__ == "__main__":
main()
|