Fooocus icon indicating copy to clipboard operation
Fooocus copied to clipboard

Allow users specify number of threads when running on CPU via the extension to --always-cpu arg

Open maxim-saplin opened this issue 2 years ago • 0 comments

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 Screenshot 2023-12-26 122338

15 threads, 72.8% seconds/iteration Screenshot 2023-12-26 125136

maxim-saplin avatar Dec 26 '23 13:12 maxim-saplin