feat: allow users to specify the number of threads when running on CPU (#1601)
* CPU_NUM_THREADS * refactor: optimize code, type is already strict --------- Co-authored-by: Manuel Schmid <manuel.schmid@odt.net>
This commit is contained in:
parent
ef1999c52c
commit
4d34f31a72
@ -100,7 +100,7 @@ vram_group.add_argument("--always-high-vram", action="store_true")
|
|||||||
vram_group.add_argument("--always-normal-vram", action="store_true")
|
vram_group.add_argument("--always-normal-vram", action="store_true")
|
||||||
vram_group.add_argument("--always-low-vram", action="store_true")
|
vram_group.add_argument("--always-low-vram", action="store_true")
|
||||||
vram_group.add_argument("--always-no-vram", action="store_true")
|
vram_group.add_argument("--always-no-vram", action="store_true")
|
||||||
vram_group.add_argument("--always-cpu", action="store_true")
|
vram_group.add_argument("--always-cpu", type=int, nargs="?", metavar="CPU_NUM_THREADS", const=-1)
|
||||||
|
|
||||||
|
|
||||||
parser.add_argument("--always-offload-from-vram", action="store_true")
|
parser.add_argument("--always-offload-from-vram", action="store_true")
|
||||||
|
@ -60,6 +60,9 @@ except:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if args.always_cpu:
|
if args.always_cpu:
|
||||||
|
if args.always_cpu > 0:
|
||||||
|
torch.set_num_threads(args.always_cpu)
|
||||||
|
print(f"Running on {torch.get_num_threads()} CPU threads")
|
||||||
cpu_state = CPUState.CPU
|
cpu_state = CPUState.CPU
|
||||||
|
|
||||||
def is_intel_xpu():
|
def is_intel_xpu():
|
||||||
|
@ -370,7 +370,7 @@ entry_with_update.py [-h] [--listen [IP]] [--port PORT]
|
|||||||
[--attention-split | --attention-quad | --attention-pytorch]
|
[--attention-split | --attention-quad | --attention-pytorch]
|
||||||
[--disable-xformers]
|
[--disable-xformers]
|
||||||
[--always-gpu | --always-high-vram | --always-normal-vram |
|
[--always-gpu | --always-high-vram | --always-normal-vram |
|
||||||
--always-low-vram | --always-no-vram | --always-cpu]
|
--always-low-vram | --always-no-vram | --always-cpu [CPU_NUM_THREADS]]
|
||||||
[--always-offload-from-vram] [--disable-server-log]
|
[--always-offload-from-vram] [--disable-server-log]
|
||||||
[--debug-mode] [--is-windows-embedded-python]
|
[--debug-mode] [--is-windows-embedded-python]
|
||||||
[--disable-server-info] [--share] [--preset PRESET]
|
[--disable-server-info] [--share] [--preset PRESET]
|
||||||
|
Loading…
Reference in New Issue
Block a user