1
mirror of https://github.com/comfyanonymous/ComfyUI.git synced 2025-08-02 23:14:49 +08:00

Add a command line argument to enable backend:cudaMallocAsync

This commit is contained in:
comfyanonymous
2023-07-17 11:00:14 -04:00
parent 3a150bad15
commit 1679abd86d
3 changed files with 11 additions and 2 deletions

10
main.py
View File

@@ -51,7 +51,6 @@ import threading
import gc
from comfy.cli_args import args
import comfy.utils
if os.name == "nt":
import logging
@@ -62,7 +61,16 @@ if __name__ == "__main__":
os.environ['CUDA_VISIBLE_DEVICES'] = str(args.cuda_device)
print("Set cuda device to:", args.cuda_device)
if args.cuda_malloc:
env_var = os.environ.get('PYTORCH_CUDA_ALLOC_CONF', None)
if env_var is None:
env_var = "backend:cudaMallocAsync"
else:
env_var += ",backend:cudaMallocAsync"
os.environ['PYTORCH_CUDA_ALLOC_CONF'] = env_var
import comfy.utils
import yaml
import execution