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

Add mps-cpu support #163

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Add mps-cpu support #163

wants to merge 8 commits into from

Conversation

Tps-F
Copy link

@Tps-F Tps-F commented Feb 8, 2023

Summary

・Adapted stablediffusion to work on M1 mac(mps).
・ Created an automatic device detection system for #147

Feature

・Support mps for txt2img.py, img2img.py, gradio and streamlit
・Add mac config(v2-inference-v-mac.yaml)

Of course, it can also run on cuda

@oscarbg
Copy link

oscarbg commented Feb 8, 2023

Hi,
nice work..
Can share perf on M1 CPU and GPU like #147 (comment) for recent Intel IPEX pull request?

@Tps-F
Copy link
Author

Tps-F commented Feb 8, 2023

This is the result in my environment for txt2img.py!

CPU Memory
Apple M1 16GB
Batch size Model name device argument Avg gen time How fast compared to cpu
1 SD2-v (768px) CPU --precision full 273s N/A
1 SD2-v (768px) MPS 100s 273%
4 SD2-v (768px) CPU --precision full 1010s N/A
4 SD2-v (768px) MPS 577s 175%
1 SD2-base (512px) CPU --precision full 271s N/A
1 SD2-base (512px) MPS 98s 276%
4 SD2-base (512px) CPU --precision full 1014s N/A
4 SD2-base (512px) MPS 600s 169%

@oscarbg
Copy link

oscarbg commented Feb 9, 2023

Thanks for testing! Hope can be merged soon!

Copy link

@kevbit kevbit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really nice work! Hopefully, this is able to be merged.

@Tps-F
Copy link
Author

Tps-F commented Apr 2, 2023

If there is a problem, I'll revert 90d4c71

@jflatow
Copy link

jflatow commented Aug 25, 2023

Can confirm this works more or less on M2 w/ 16GB (although I'm not sure how you generated 768x768, that crashes for me in allocating a buf)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants