stable-diffusion icon indicating copy to clipboard operation
stable-diffusion copied to clipboard

Please default to CPU-only PyTorch if no suitable GPU is detected.

Open fragmentshader2022 opened this issue 2 years ago • 13 comments

PyTorch is defaulting to NVIDIA GPU, but it would be good to fall back to CPU-only if no suitable GPU is found.

Something like this perhaps? https://github.com/ModeratePrawn/stable-diffusion-cpu/pull/1

This would provide a better out-of-the-box setup experience for users with unsupported GPU’s (AMD) until those versions are implemented, and to users like me who have no GPU but want to run locally.

fragmentshader2022 avatar Aug 23 '22 12:08 fragmentshader2022

See: #56

HenkPoley avatar Aug 23 '22 12:08 HenkPoley

@HenkPoley Thanks!

fragmentshader2022 avatar Aug 23 '22 16:08 fragmentshader2022

@HenkPoley Thanks!

Hi, I am pretty new but did you figure out how to get it to run with CPU only?

MojoJojo43 avatar Aug 26 '22 17:08 MojoJojo43

right here https://huggingface.co/spaces/stabilityai/stable-diffusion

breadbrowser avatar Aug 27 '22 01:08 breadbrowser

right here https://huggingface.co/spaces/stabilityai/stable-diffusion

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.

MojoJojo43 avatar Aug 27 '22 03:08 MojoJojo43

right here https://huggingface.co/spaces/stabilityai/stable-diffusion

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.

http://beta.dreamstudio.ai/

breadbrowser avatar Aug 27 '22 12:08 breadbrowser

right here https://huggingface.co/spaces/stabilityai/stable-diffusion

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.

http://beta.dreamstudio.ai/

and that one is paid unless you want to keep switching IP's and creating accounts and still censors your prompts.

MojoJojo43 avatar Aug 27 '22 15:08 MojoJojo43

With diffusers it's quite easy to run it on CPU only:

# !pip install diffusers
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")

# remove VAE encoder as it's not needed
del pipe.vae.encoder

prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt)["sample"][0] 

patrickvonplaten avatar Aug 29 '22 09:08 patrickvonplaten

right here https://huggingface.co/spaces/stabilityai/stable-diffusion

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.

http://beta.dreamstudio.ai/

and that one is paid unless you want to keep switching IP's and creating accounts and still censors your prompts.

wrong, just use temp mail. when you run out log out and sign up with a temp mail email. there is no IP tracker. novel ai has IP trackers.

breadbrowser avatar Aug 29 '22 16:08 breadbrowser

With diffusers it's quite easy to run it on CPU only:

# !pip install diffusers
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")

# remove VAE encoder as it's not needed
del pipe.vae.encoder

prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt)["sample"][0] 

where do i put this? @patrickvonplaten

warior456 avatar Dec 10 '22 16:12 warior456

Sustain! Where to put?

Sivll avatar Sep 24 '23 10:09 Sivll

damn... so clow with CPU.. is it safe? it consumes >> 100% of cpu amount. I have quad core Intel i5. Hope it means 25% usage per core))

del pipe.vae.encoder prompt = "a photo of an astronaut riding a horse on mars" image = pipe(prompt)["sample"][0] 8%|██████▌ | 4/50 [02:09<22:20, 29.13s/it]

And I've got such message: Cannot initialize model with low cpu memory usage because accelerate was not found in the environment. Defaulting to low_cpu_mem_usage=False. It is strongly recommended to install accelerate for faster and less memory-intense model loading. You can do so with:

pip install accelerate

Can I install it without exit from interpreter >>>???


And where generated image wil be saved????

Sivll avatar Sep 25 '23 05:09 Sivll

after process finished an error appears Traceback (most recent call last): File "", line 1, in File "/Users/semkovigor/sd/MetalDiffusion/venv/lib/python3.11/site-packages/diffusers/utils/outputs.py", line 88, in getitem return inner_dict[k] ~~~~~~~~~~^^^ KeyError: 'sample'

what should I do to fix it?

Sivll avatar Sep 25 '23 06:09 Sivll