Fooocus
Fooocus copied to clipboard
Allow users specify number of threads when running on CPU via the extension to --always-cpu arg
I have changed the --always-cpu argument to integer, if in the command line this argument is followed by a number greater than 0 it will be used in torch.set_num_threads() and override the default value.
On my 8 core AMD 7840U which supports 16 threads I noticed I got ~70% CPU utilization while running image generation. As i discovered PyTorch doesn't seem to be benefiting from SMT and sets the number of threads to the number of physical cores.
By increasing the number of threads from default 8 to 15 I received ~5% performance increase and 100% CPU utilization (see screenshots).
8 threads, 78.2 seconds/iteration
15 threads, 72.8% seconds/iteration