lllyasviel / Fooocus

Focus on prompting and generating
GNU General Public License v3.0
38.47k stars 5.14k forks source link

Is it able to run under the CPU? #798

Closed libai-lab closed 6 months ago

libai-lab commented 8 months ago

Is it able to run under the CPU?It would be nice if it could be optimized to run under the CPU, I think stable diffusion has some that can run under the CPU, and if it maybe it would be great

barepixels commented 8 months ago

i hear under GPU will be 100x slower

stubkan commented 8 months ago

Yes, - they usually require smaller models/fewer steps as CPU power is less than GPU power, so the output is possibly lower quality.

You can try these for CPU generation;

https://github.com/rupeshs/fastsdcpu - this is using a different system (latent consistency) that only uses 1-4 steps instead of the 20+ SD uses. https://github.com/luosiallen/latent-consistency-model

https://github.com/rupeshs/diffusionmagic - this is using a reduced size SDXL model.

JarekDerp commented 7 months ago

You can run Fooocus under the CPU, I tried that yesterday but it was veeery slow. Only 8 it took over 5 minutes to generate one image as it was running 50s/it on Ryzen 5 5500. Although I have to say the image was quite good in quality and resolution. It would be faster if not for the image sizes that Fooocus forces on you. Smaller images <512 on each side would result in a much better times albeit poorer quality.

JarekDerp commented 7 months ago

To run it under CPU, you need to modify the run.bat like this: .\python_embeded\python.exe -m pip uninstall torch torchvision torchaudio torchtext functorch xformers -y .\python_embeded\python.exe -m pip install torch-directml .\python_embeded\python.exe -s Fooocus\entry_with_update.py --CPU pause

You can also add --CPU --preset anime or --CPU --preset realistic if you want to focus on the given style, otherwise don't add anything after the "--CPU".

libai-lab commented 7 months ago

Is there a way to integrate and use the LCM model? It can be used on the CPU, and it only takes a few minutes for me to generate images. If it is on the GPU, it only takes less than 2 seconds. If your model is relatively streamlined, it should be faster. Is there a way to integrate it

JarekDerp commented 7 months ago

By the look of it, LCM is a Lora. You should be able to download the .safetensor file, paste it in the models/loras folder of fooocus and select it in the advanced settings. I'm not sure if you can select how many steps it takes to generate image. I've seen "Extra Speed" or something like this and it selects 8 steps, but it still took about 5 minutes for one image on my CPU.

stubkan commented 7 months ago

LCM is already in Fooocus. You select the "Extreme Speed" or whatever it is option to activate the LCM model in the settings tab

trirpi commented 7 months ago

To run it under CPU, you need to modify the run.bat like this: .\python_embeded\python.exe -m pip uninstall torch torchvision torchaudio torchtext functorch xformers -y .\python_embeded\python.exe -m pip install torch-directml .\python_embeded\python.exe -s Fooocus\entry_with_update.py --CPU pause

You can also add --CPU --preset anime or --CPU --preset realistic if you want to focus on the given style, otherwise don't add anything after the "--CPU".

This worked for me on windows! Only thing is CPU should be lowercase and I had to drop the pause.

So I just did the following:

.\python_embeded\python.exe -m pip uninstall torch torchvision torchaudio torchtext functorch xformers -y
.\python_embeded\python.exe -m pip install torch-directml
.\python_embeded\python.exe -s Fooocus\entry_with_update.py --cpu
arham4312 commented 7 months ago

Can someone guide me how to run it on intel macbook pro 2018?

Jonapy commented 7 months ago

To run it under CPU, you need to modify the run.bat like this: .\python_embeded\python.exe -m pip uninstall torch torchvision torchaudio torchtext functorch xformers -y .\python_embeded\python.exe -m pip install torch-directml .\python_embeded\python.exe -s Fooocus\entry_with_update.py --CPU pause You can also add --CPU --preset anime or --CPU --preset realistic if you want to focus on the given style, otherwise don't add anything after the "--CPU".

This worked for me on windows! Only thing is CPU should be lowercase and I had to drop the pause.

So I just did the following:

.\python_embeded\python.exe -m pip uninstall torch torchvision torchaudio torchtext functorch xformers -y
.\python_embeded\python.exe -m pip install torch-directml
.\python_embeded\python.exe -s Fooocus\entry_with_update.py --cpu

I got this when changing the run.bat file and running it:

entry_with_update.py: error: unrecognized arguments: --cpu

lllyasviel commented 7 months ago

see also all cmd flags here: https://github.com/lllyasviel/Fooocus?tab=readme-ov-file#all-cmd-flags

CPU is --always-cpu

axia89 commented 6 months ago

hi everyone . i modified the run.bat but it closes after installing some dependencies. i have an integrated intel arc gpu . any help how to make it work . it was working before i modified the run bat file . the problem is no nvidia gpu found , so i was unable to use it . please help !