News for hackers. Stuff that matters.
Re:Try Stable Diffusion's Img2Img Mode by comex on Sunday August 28, 2022 @09:41PM (#32633948)
If you have a GPU with >4GB of VRAM and you want to run this locally, here's a fork of the Stable Diffusion repo with a convenient web UI:

https://github.com/hlky/stable-diffusion

It supports both txt2img and img2img. (Not affiliated.)

Edit: Incidentally, I tried running it on a CPU. It is possible, but it took 3 minutes instead of 10 seconds to produce an image. It also required me to hack up the script in a really gross way. Perhaps there is a script somewhere that properly supports this.

Re:Try Stable Diffusion's Img2Img Mode by kgwgk on Monday August 29, 2022 @01:41AM (#32635107)
There are as well forks for the GPU in Apple’s M1 chips:

https://github.com/magnusviri/stable-diffusion

Re:Try Stable Diffusion's Img2Img Mode by francisduvivier on Monday August 29, 2022 @08:32AM (#32637364)
Anyone knows how fast this runs on an m1 macbook air?
Re:Try Stable Diffusion's Img2Img Mode by bjtitus on Monday August 29, 2022 @09:15AM (#32637788)
Takes anywhere from 30s-1.5m on my M1 Max.
Re:Try Stable Diffusion's Img2Img Mode by BatteryMountain on Monday August 29, 2022 @07:29AM (#32636878)
Nvidia GTX 1660 Super with 6GB of VRAM.

I do runs at 384px by 384px, with batch size of 1. Sampling method has almost no impact on memory. Using k_euler with 30 steps renders an image in 10 to 20 seconds. The biggest thing that affect rending speed is the steps and the resolution, so 512x512 with C 50 using ddim is much slower than 256x256 with C 25 using k_euler.

The sampling methods run mostly in the same timelines, but the k_euler one can produce viable output at lower C values, meaning it is faster than the rest.

Don't add gfpgan in the same pipeline, as it takes more vram.

I'm running it on Windows 10 with latest drivers. I set the python process to Realtime priority in task manager (makes a slight difference!). Have not tried it on Linux.

Re:Try Stable Diffusion's Img2Img Mode by gitfan86 on Monday August 29, 2022 @09:29AM (#32637973)
I'm running 1660 ti on Windows 11.

I'm thinking about getting a 3090 so that I can make higher resolution images.

Gfpgan runs much faster for me 5 seconds per picture

Re:Try Stable Diffusion's Img2Img Mode by machineleaning on Monday August 29, 2022 @11:30AM (#32639458)
What resolution could you get on a 3090?
Re:Try Stable Diffusion's Img2Img Mode by BatteryMountain on Tuesday August 30, 2022 @09:49AM (#32650381)
Good way to know (if not found online) is to start at 512x512 if you have a card with 12GB VRAM and try to increment it (the ui slider increases it by 64px for each increment) and backtrack when you start getting "cuda out of memory" errors. I've seen some renders on discord where the sizes are well above 1000px, so they must have had a 16/24GB cards or something similar. In the research context, they are used to using 40GB/80GB hardware (and perhaps multiples) to train and render. So quite remarkable that it works on consumer hardware at this point.

edit: on second thought, they most likely rendered at 512px but then ran it through an upscaler model. I've been meaning to hook mine up but kinda forgot to try.

Re:Try Stable Diffusion's Img2Img Mode by gitfan86 on Monday August 29, 2022 @04:44PM (#32643324)
No idea, things are changing very quickly now
Re:Try Stable Diffusion's Img2Img Mode by jtolmar on Monday August 29, 2022 @12:50AM (#32634907)
I'm impressed that running it on CPU only made it ~20x slower. How did you do it?
Re:Try Stable Diffusion's Img2Img Mode by lkois on Monday August 29, 2022 @01:03AM (#32634958)
Nah that's normal. It's why GPUs are the usual thing for AI. Any crap, old, weak gpu with 4gb memory would run circles around a cpu

It's often easier to actually get models to run on CPU, due to simpler install configs and more available memory. Just painful to get a result out of it. Which might help keep the install simple, because it's not even worth optimizing

Re:Try Stable Diffusion's Img2Img Mode by kgwgk on Monday August 29, 2022 @02:44AM (#32635385)
> Any crap, old, weak gpu with 4gb memory would run circles around a cpu

Not really.

https://news.ycombinator.com/item?id=32635086

I’m not even sure it works well - if at all - with 4Gb.

In any case, it’s impressive even if it takes minutes. And it’s not like you need to be there to make it work. You can create a list of prompts, let it do its thing and check the results later.

Re:Try Stable Diffusion's Img2Img Mode by hwers on Monday August 29, 2022 @04:09AM (#32635794)
I have 4 gb and it takes about 9 seconds for me :) (Tho at 448x448 but there’s no real difference in quality.)
Re:Try Stable Diffusion's Img2Img Mode by kgwgk on Monday August 29, 2022 @04:24AM (#32635899)
Good to know it works. That’s not a crap, old, weak gpu, I guess.

I’ve not tried that size but I tried 256x256 and it was too small to get interesting results - maybe there are some parameters that can be adjusted to improve it though.

Re:Try Stable Diffusion's Img2Img Mode by stavros on Monday August 29, 2022 @07:07AM (#32636720)
The GP is asking why it's only 20x slower, rather than more slow.
Re:Try Stable Diffusion's Img2Img Mode by lkois on Monday August 29, 2022 @12:00PM (#32639790)
Ha yep I see that now, on a reread. My bad
Re:Try Stable Diffusion's Img2Img Mode by stavros on Monday August 29, 2022 @12:16PM (#32639977)
It's OK, I missed the "only" the first time around and read it the same way as you.
Re:Try Stable Diffusion's Img2Img Mode by acidburnNSA on Monday August 29, 2022 @12:45AM (#32634880)
Just tried it on Ubuntu 22.04. And it's working! Had to install python-is-python3 and conda, but it's up now. Fun, thanks.
Re:Try Stable Diffusion's Img2Img Mode by TuringTest on Monday August 29, 2022 @02:54AM (#32635418)
How do you set up the model? Instructions only say "Download the model checkpoint. (e.g. from huggingface)", but I can't find instructions there on how to find a ckpt file, nor exactly what file should I look for.
Re:Try Stable Diffusion's Img2Img Mode by nilsb on Monday August 29, 2022 @03:03AM (#32635450)
Re:Try Stable Diffusion's Img2Img Mode by nickthegreek on Monday August 29, 2022 @11:38AM (#32639532)
Thank you, this saved me a lot of frustration.
Re:Try Stable Diffusion's Img2Img Mode by asicsp on Monday August 29, 2022 @01:32AM (#32635071)
Can you share your script for running on CPU?
Re:Try Stable Diffusion's Img2Img Mode by ArneBab on Tuesday August 30, 2022 @03:17AM (#32647536)
python optimizedSD/optimized_txt2img.py --device cpu --precision full --prompt "…" --H 512 --W 512 --n_iter 1 --n_samples 1 --ddim_steps 50
Re:Try Stable Diffusion's Img2Img Mode by asicsp on Tuesday August 30, 2022 @03:44AM (#32647712)
Thank you. There was a also a related submission for running on CPU: https://news.ycombinator.com/item?id=32642255

I'm planning to try it out this weekend. But not really hopeful. I only have 8GB ram, and mine is a cheap Intel CPU that doesn't even have AVX.

Re:Try Stable Diffusion's Img2Img Mode by MichaelDickens on Monday August 29, 2022 @01:35AM (#32635086)
What kind of GPU do you have? It takes several minutes to produce an image on my 1070.
Re:Try Stable Diffusion's Img2Img Mode by elaus on Monday August 29, 2022 @03:37AM (#32635615)
Takes 3 minutes (for a prompt resulting in a set of 4 images) on my 1080 as well. Really astonished that it takes GP about the same time using just a CPU. Seems like the older generation of GPUs isn't much better than CPUs in regards to ML stuff.
Re:Try Stable Diffusion's Img2Img Mode by krisoft on Monday August 29, 2022 @05:37AM (#32636265)
> Really astonished that it takes GP about the same time using just a CPU.

GP talks about generating a single image while you talk about generating 4.

Re:Try Stable Diffusion's Img2Img Mode by stingraycharles on Monday August 29, 2022 @02:08AM (#32635212)
A 1070 isn’t very powerful for ML compared to more recent GPUs, so several minutes sounds about right.
Re:Try Stable Diffusion's Img2Img Mode by SirYandi on Monday August 29, 2022 @03:39AM (#32635622)
To add another data point, my GTX1080 takes ~60 sec to generate a pair of 500x500 images using txt2img. Haven't tried img2img yet as the UI package I went with is a bit buggy with it
Re:Try Stable Diffusion's Img2Img Mode by anhner on Monday August 29, 2022 @03:45AM (#32635651)
also on a 1070, I can generate an image in ~15 seconds, surely you're doing something wrong.
Re:Try Stable Diffusion's Img2Img Mode by freeqaz on Monday August 29, 2022 @03:52AM (#32635692)
What settings are you using it the people with 1080s above you are taking 3 minutes?
Re:Try Stable Diffusion's Img2Img Mode by anhner on Monday August 29, 2022 @07:40AM (#32636984)
I'm using lstein's repository which loads the models and keeps them in memory. Then, for some diffusers 16 steps is enough to come up with a usable image (and using more steps will only add details, most of the time won't change much).

This is for the initial "exploration" step of the process. Once I like an image I typically play with the settings, then in the final step run with a large number of steps (and maybe even use upscaling).

So, default 512x512 size, 16 steps and default for the rest of the settings (I believe 7.5 scale, 0.75 strength).

Having said that, I also tried the official Docker image for stable diffusion and with the default values it generated an image in about 40 seconds.

Re:Try Stable Diffusion's Img2Img Mode by bambax on Monday August 29, 2022 @06:58AM (#32636669)
What are good and reasonably priced GPUs for this (<$250, possibly less)?
Re:Try Stable Diffusion's Img2Img Mode by simcop2387 on Monday August 29, 2022 @07:15AM (#32636775)
Not sure exact pricing but look for a used maxwell (geforce 1000 series) nvidia gpu i'd bet. A quadro m2000 with 4gb of ram was about 100 on ebay a short bit ago
Re:Try Stable Diffusion's Img2Img Mode by bambax on Tuesday August 30, 2022 @04:25AM (#32647973)
Thanks! A Quadro m2000 can still be found fr around 100 today, but I found an m4000 for 150, and ordered that... We'll see...
Re:Try Stable Diffusion's Img2Img Mode by ilaksh on Monday August 29, 2022 @07:16AM (#32636778)
Amazing. Anyone know of a fork where this is hosted on a cloud GPU? Or any existing hosting of this?
Re:Try Stable Diffusion's Img2Img Mode by fragmede on Monday August 29, 2022 @12:23PM (#32640058)
There’s a Colab implementation (Google hosted GPU) linked to from https://www.youtube.com/watch?v=Xur1JeRjjOI
Re:Try Stable Diffusion's Img2Img Mode by outdoorblake on Monday August 29, 2022 @01:10PM (#32640708)
here is a serverless GPU template for Stable Diffusion hosted on Banana's cloud platform. template: https://github.com/bananaml/serverless-template-stable-diffu... setup demo: https://www.banana.dev/blog/how-to-deploy-stable-diffusion-t...
Re:Try Stable Diffusion's Img2Img Mode by nickthegreek on Monday August 29, 2022 @11:36AM (#32639514)
Got this working on my 8gb 3070. 7-8s per image with default settings. Thanks for posting this!