Add optimization --cuda-stream

See also the readme for more details
This commit is contained in:
lllyasviel
2024-02-24 14:00:48 -08:00
committed by GitHub
parent 0f09d98814
commit 434ca2169f
9 changed files with 63 additions and 73 deletions

View File

@@ -59,6 +59,9 @@ def initialize_forge():
import modules_forge.patch_basic
modules_forge.patch_basic.patch_all_basics()
from modules_forge import stream
print('CUDA Stream Activated: ', stream.using_stream)
from modules_forge.shared import diffusers_dir
if 'TRANSFORMERS_CACHE' not in os.environ:

View File

@@ -2,7 +2,7 @@
import torch
from modules import shared
from ldm_patched.modules import args_parser
from ldm_patched.modules import model_management
@@ -56,14 +56,12 @@ def get_new_stream():
return None
if shared.opts.use_non_streamlined_lowvram:
current_stream = None
mover_stream = None
using_stream = False
else:
current_stream = None
mover_stream = None
using_stream = False
if args_parser.args.cuda_stream:
current_stream = get_current_stream()
mover_stream = get_new_stream()
using_stream = current_stream is not None and mover_stream is not None
if not using_stream:
print('Stream is not used.')