-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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 for using CPU if no CUDA device is detected #56
base: main
Are you sure you want to change the base?
Conversation
Code changes from CompVis/latent-diffusion#123
Add files via upload
I have a pull request that looks like it changes the exact same lines as you, except my changes are for Apple Silicon GPU support. The code in my PR tries cuda, then mps (for Apple), then cpu. #47 |
Thanks for the heads up! I would recommend your PR over mine, since it has more functionality. Stable Diffusion for all! |
This pull request will fix #62 |
Are there any instructions on exactly how to accomplish this? Like a tutorial or something to follow? |
Hi, yeah that's a really great option albeit a limited one. Can't control the size of the images and also can't use any adult terms because it is censored. |
|
If you download my fork, you can just run the commands as is in the Readme, and it should detect if you have a GPU or not. If not, then it will switch to CPU and run the inference. |
YOU DA MAN/WOMAN!!! Absolutely incredible work that you all have done here. Mind boggling for sure. Quick question, I see that you guys/gals have coded a moderator to catch explicit outputs? My hat's off to you guys/gals. I haven't got it running yet but fingers crossed! ;-) |
Verified this patch works. Painfully slow, but it works! |
Hi, I am having one helluva time and am hoping you might be able to take a look to see what I am doing wrong. Here is what I have done and am doing:
And after that it seems to get going but ultimately stops with an error that reads:
I have been troubleshooting since 8am and it's now almost 12:00 am my time and I am still no closer to figuring this out lol. Thanks in advance!!! |
Can you post the full output of the error you get after you run the inference script? |
There's a missed instance of That needs to also be updated to: in img2img. |
Hi there..... So, I have never used Ubuntu.......don't even really know anything about the windows cmd prompt other than it can do some nifty and nasty things to your pc :-) HAHA! I brute forced my way out of all other possibilities and then started thinking about the env folder structures and whether or not I was in the right folders while executing all the commands. So I ended up removing EVERYTHING and starting from scratch....... AND IT WORKS!!!!!! WHOOOOOOHOOOOOO! It's about as slow as molasses but hey, just means I need to invest in a good GPU if I want to do this for really realz ;-) I have one final question. My machines GPU cannot be upgraded and is too old for Stable Diffusion. Would it be possible to use an eGPU? If so, what type should I be looking at to ensure compatibility? I'm not looking to spend over $500 on it either....the more affordable the better ;-) Thanks for all the hard work and for being there to help out. Much appreciated! |
Hi, is it possible to run this on an Oracle Cloud Ampere A1 with ubuntu as the os? And if so does having 4 cores speed it up in any way? |
Hello, when running the img2img script I get this error, https://blazebin.io/ishkwmjgmngo. but, my txt2img script works great! So thank you very much for this fork and the time you spent on it! |
Made img2img.py CPU compatible as well.
Wong folder
Fix img2img.py for cpu code.
I just merged an updated img2img.py, so it should work now. I forgot to modify that script's code originally. Thanks to everyone who pointed it out, and SpandexWizard for applying the fix. |
added cpu support to img2img.py
My graphics card has CUDA, but doesn't have enough memory to run. I have plenty of RAM though. Would there be a way to choose to run on the CPU then? |
@Zylann Set env variable CUDA_VISIBLE_DEVICES="". To do that:
|
@ModeratePrawn thanks for this. Works great on my system (AMD GPU, not Nvidia GPU). I just enter prompts like vanilla stable-diffusion and it defaults to CPU. |
@agajdosi Oh ok. I just thought that instead of hardcoding a particular device or behavior in multiple places of the code, that the choice could be done up-front in just one place, in turn allowing to make a choice much more easily. Thanks for the tip! This PR also helped me tweaking the code, it works well! |
It was painful, but I've verified that this PR at commit d68cd0d merged into CompVis/main at 69ae4b3 works. My laptop:
And running through the tutorial:
I ran this late last night, went to bed, and saw some astronauts on horses. QA'ed, it works! Edit: added OS version |
@bfung will you try the https://github.com/lstein/stable-diffusion version and see if it works? We added a lot of macOS arm support and I'm curious if it works on your Intel also. What is your OS? |
@magnusviri I'll take a look and give it a shot in next few days. I was inspecting my laptop's hardware and noticed that it has a The OS is 🤞 for |
@ModeratePrawn is there any way to utilize more CPU cores? On Windows 11 21H2 I'm getting an average of 10s/it, which isn't too bad, but stable-diffusion only uses about ~50% of my CPU (12c/24t):
If I can increase CPU utilization by about 50% (to about 75% total), I could get a roughly proportional decrease in run time. |
From what I learned from my PC, your GT 650M is only cuda compatible up to 3.0 and pytorch dropped cuda 3.0 years ago in pytorch version 0.31. I'm curious if you will actually get your GPU to run Diffusion. |
Following up on my comment and to recap the information: This PR works on CPU on a 10 year old macI have a ~10 year old mac laptop with the following specs:
GPU on 10 year old mac?
With my old laptop hardware and OS version, the https://github.com/lstein/stable-diffusion version didn't work for me when using
On the bright side, it looks like other people have gotten the
Hope this info helps - cheers all. |
Added mse loss
Can this be merged? support for MPS would be great too. thanks. |
On my windows 10 machine without GPU and setting I still get below error
|
Code from CompVis/latent-diffusion#123 applied to Stable Diffusion and tested on CPU.
It is slow, as expected, but works.
Allows for running on the CPU if no CUDA device is detected instead of just giving a runtime error.
This should allow for more people to experiment even without owning an nvidia GPU