Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Feb 25, 2024

Conversation

maxim-saplin
Copy link
Contributor

@maxim-saplin maxim-saplin commented Dec 26, 2023

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

@mashb1t mashb1t added the Size M medium change, isolated, testing with care label Feb 9, 2024
@mashb1t mashb1t added this to the 2.2.0 milestone Feb 24, 2024
@mashb1t mashb1t changed the base branch from main to develop February 25, 2024 16:13
@mashb1t mashb1t merged commit 4d34f31 into lllyasviel:develop Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Size M medium change, isolated, testing with care
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants