AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
141.09k stars 26.68k forks source link

Can I run it on cpu mode only? #2334

Closed frank01100110 closed 1 year ago

frank01100110 commented 2 years ago

If so could you tell me how?

brkirch commented 2 years ago

Try python webui.py --use-cpu SD GFPGAN BSRGAN ESRGAN SCUNet CodeFormer

Centurion-Rome commented 2 years ago

Try python webui.py --use-cpu SD GFPGAN BSRGAN ESRGAN SCUNet CodeFormer

Should be added into readme.md and wiki ;)

ClashSAN commented 1 year ago

https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/fdef8253a43ca5135923092ca9b85e878d980869 new choise --use-cpu --all

DuckyBlender commented 1 year ago

fdef825 new choise --use-cpu --all

Correction: --use-cpu all

pangzheng commented 1 year ago

python webui.py --use-cpu --all

usage: webui.py [-h] [--config CONFIG] [--ckpt CKPT] [--ckpt-dir CKPT_DIR] [--gfpgan-dir GFPGAN_DIR] [--gfpgan-model GFPGAN_MODEL] [--no-half] [--no-half-vae] [--no-progressbar-hiding] [--max-batch-count MAX_BATCH_COUNT] [--embeddings-dir EMBEDDINGS_DIR] [--hypernetwork-dir HYPERNETWORK_DIR] [--localizations-dir LOCALIZATIONS_DIR] [--allow-code] [--medvram] [--lowvram] [--lowram] [--always-batch-cond-uncond] [--unload-gfpgan] [--precision {full,autocast}] [--share] [--ngrok NGROK] [--ngrok-region NGROK_REGION] [--codeformer-models-path CODEFORMER_MODELS_PATH] [--gfpgan-models-path GFPGAN_MODELS_PATH] [--esrgan-models-path ESRGAN_MODELS_PATH] [--bsrgan-models-path BSRGAN_MODELS_PATH] [--realesrgan-models-path REALESRGAN_MODELS_PATH] [--scunet-models-path SCUNET_MODELS_PATH] [--swinir-models-path SWINIR_MODELS_PATH] [--ldsr-models-path LDSR_MODELS_PATH] [--xformers] [--force-enable-xformers] [--deepdanbooru] [--opt-split-attention] [--opt-split-attention-invokeai] [--opt-split-attention-v1] [--disable-opt-split-attention] [--use-cpu {all,sd,interrogate,gfpgan,bsrgan,esrgan,scunet,codeformer} [{all,sd,interrogate,gfpgan,bsrgan,esrgan,scunet,codeformer} ...]] [--listen] [--port PORT] [--show-negative-prompt] [--ui-config-file UI_CONFIG_FILE] [--hide-ui-dir-config] [--ui-settings-file UI_SETTINGS_FILE] [--gradio-debug] [--gradio-auth GRADIO_AUTH] [--gradio-img2img-tool {color-sketch,editor}] [--opt-channelslast] [--styles-file STYLES_FILE] [--autolaunch] [--theme THEME] [--use-textbox-seed] [--disable-console-progressbars] [--enable-console-prompts] [--vae-path VAE_PATH] [--disable-safe-unpickle] [--api] [--nowebui] webui.py: error: argument --use-cpu: expected at least one argument

pangzheng commented 1 year ago

python webui.py --use-cpu SD GFPGAN BSRGAN ESRGAN SCUNet CodeFormer --all

Traceback (most recent call last): File "/Users/Prometheus_1/github/ai/stable-diffusion-webui/modules/ui.py", line 212, in f res = list(func(*args, kwargs)) File "/Users/Prometheus_1/github/ai/stable-diffusion-webui/webui.py", line 63, in f res = func(*args, kwargs) File "/Users/Prometheus_1/github/ai/stable-diffusion-webui/modules/txt2img.py", line 44, in txt2img processed = process_images(p) File "/Users/Prometheus_1/github/ai/stable-diffusion-webui/modules/processing.py", line 400, in process_images uc = prompt_parser.get_learned_conditioning(shared.sd_model, len(prompts) [p.negative_prompt], p.steps) File "/Users/Prometheus_1/github/ai/stable-diffusion-webui/modules/prompt_parser.py", line 138, in get_learned_conditioning conds = model.get_learned_conditioning(texts) File "/Users/Prometheus_1/github/ai/stable-diffusion-webui/repositories/stable-diffusion/ldm/models/diffusion/ddpm.py", line 558, in get_learned_conditioning c = self.cond_stage_model(c) File "/Users/Prometheus_1/miniconda/envs/web-ui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(input, kwargs) File "/Users/Prometheus_1/github/ai/stable-diffusion-webui/modules/sd_hijack.py", line 334, in forward z1 = self.process_tokens(tokens, multipliers) File "/Users/Prometheus_1/github/ai/stable-diffusion-webui/modules/sd_hijack.py", line 350, in process_tokens outputs = self.wrapped.transformer(input_ids=tokens, output_hidden_states=-opts.CLIP_stop_at_last_layers) File "/Users/Prometheus_1/miniconda/envs/web-ui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, kwargs) File "/Users/Prometheus_1/miniconda/envs/web-ui/lib/python3.10/site-packages/transformers/models/clip/modeling_clip.py", line 722, in forward return self.text_model( File "/Users/Prometheus_1/miniconda/envs/web-ui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, kwargs) File "/Users/Prometheus_1/miniconda/envs/web-ui/lib/python3.10/site-packages/transformers/models/clip/modeling_clip.py", line 643, in forward encoder_outputs = self.encoder( File "/Users/Prometheus_1/miniconda/envs/web-ui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, *kwargs) File "/Users/Prometheus_1/miniconda/envs/web-ui/lib/python3.10/site-packages/transformers/models/clip/modeling_clip.py", line 574, in forward layer_outputs = encoder_layer( File "/Users/Prometheus_1/miniconda/envs/web-ui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(input, kwargs) File "/Users/Prometheus_1/miniconda/envs/web-ui/lib/python3.10/site-packages/transformers/models/clip/modeling_clip.py", line 316, in forward hidden_states = self.layer_norm1(hidden_states) File "/Users/Prometheus_1/miniconda/envs/web-ui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "/Users/Prometheus_1/miniconda/envs/web-ui/lib/python3.10/site-packages/torch/nn/modules/normalization.py", line 189, in forward return F.layer_norm( File "/Users/Prometheus_1/miniconda/envs/web-ui/lib/python3.10/site-packages/torch/nn/functional.py", line 2503, in layer_norm return torch.layer_norm(input, normalized_shape, weight, bias, eps, torch.backends.cudnn.enabled) RuntimeError: "LayerNormKernelImpl" not implemented for 'Half'

Lewington-pitsos commented 1 year ago

i get the same error when generating

brkirch commented 1 year ago

Add the --no-half option: python webui.py --no-half --use-cpu all

pangzheng commented 1 year ago

i solved the problem

python webui.py --precision full --no-half --use-cpu SD GFPGAN BSRGAN ESRGAN SCUNet CodeFormer --all

lrq3000 commented 1 year ago

@pangzheng 's solution almost worked for me, but not fully. When trying to run python webui.py, I still got a ImportError: fastapi not found exception.

Here's what worked for me, by tweaking some more myself and using complementary tips from #2733, this works in colabs and should work in localhost with minor modifications (as described in comments):

%env CUDA_VISIBLE_DEVICES=-1 # setup an environment variable to signal that there is no GPU to pyTorch, tip from https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/2733#issuecomment-1281311086 — this is using jupyter % magic, for the pure-python alternative: import os \n os.environ['CUDA_VISIBLE_DEVICES'] = -1
!python launch.py --share --precision full --no-half --use-cpu SD GFPGAN BSRGAN ESRGAN SCUNet CodeFormer --all --skip-torch-cuda-test

Note: Do NOT use --force-enable-xformers and do not even pip install xformers, otherwise it will force use of the GPU, see #5672.

usamaehsan commented 1 year ago

@irq3000 i am getting this error : NotImplementedError: No operator found for this attention: AttentionOpDispatch(dtype=torch.float32, device=device(type='cpu'), k=512, has_dropout=False, attn_bias_type=<class 'NoneType'>, kv_len=4096, q_len=4096, kv=512, batch_size=1, num_heads=1, has_custom_scale=False, requires_grad=False)

lrq3000 commented 1 year ago

I think you have xformers installed, you need to pip uninstall xformers, otherwise xformers require a gpu as they were not implemented for cpus.

4 févr. 2023 08:42:15 usamaClick @.***>:

@irq3000 i am getting this error : NotImplementedError: No operator found for this attention: AttentionOpDispatch(dtype=torch.float32, device=device(type='cpu'), k=512, has_dropout=False, attn_bias_type=<class 'NoneType'>, kv_len=4096, q_len=4096, kv=512, batch_size=1, num_heads=1, has_custom_scale=False, requires_grad=False)

— Reply to this email directly, view it on GitHub[https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/2334#issuecomment-1416688570], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AAIRFXWJ6PIAO7STX6RWXDLWVYB5NANCNFSM6AAAAAARC3QUEI]. You are receiving this because you commented.[Image de pistage][https://github.com/notifications/beacon/AAIRFXSMVBSRFMPFT3LOY7LWVYB5NA5CNFSM6AAAAAARC3QUEKWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSUODZ3U.gif]

yanmingsohu commented 1 year ago

--no-half --use-cpu all

windows: webui --no-half --use-cpu all

linux: ./webui.sh --no-half --use-cpu all

This script runs in a virtual environment, and all libraries are housed in the 'stable-diffusion-webui/venv/Lib/site-packages' directory.

Art-afk commented 1 year ago

--no-half --use-cpu all

windows: webui --no-half --use-cpu all

linux: ./webui.sh --no-half --use-cpu all

This script runs in a virtual environment, and all libraries are housed in the 'stable-diffusion-webui/venv/Lib/site-packages' directory.

thnx! work for me! =) MacBook i7

Art-afk commented 1 year ago

I'm not a programmer and I don't understand where to write these arguments, Need instructions, pls!! I added in the webui-user.bat file to the line set COMMANDLINE_ARGS=--skip-torch-cuda-test --precision full --no-half --use-cpu SD GFPGAN BSRGAN ESRGAN SCUNet CodeFormer --all But I get a constant error "module not found " no half/no precision full/etc. Or another: RuntimeError: "LayerNormKernelImpl" not implemented for 'Half' What am I doing wrong? Where to write it?

do u have video card? if no u need create bat file "start.bat" in write "webui --no-half --use-cpu all" maybe like this "webui.bat --no-half --use-cpu all" or "webui.py --no-half --use-cpu all"

showkeyjar commented 1 year ago

--use-cpu all can not working with plugin openpose edtior?

adityasohoni commented 1 year ago

python ./launch.py --xformers --share --use-cpu USE_CPU  2 ✘  11s   stable-diffusion-venv 

Python 3.10.12 (main, Jul 5 2023, 19:22:19) [GCC 11.2.0] Commit hash: 2c1bb46c7ad5b4536f6587d327a03f0ff7811c5d Installing requirements for Web UI Launching Web UI with arguments: --xformers --share --use-cpu USE_CPU Loading weights [e1441589a6] from /home/aditya/Documents/LLMs/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned.ckpt [1] 11417 killed python ./launch.py --xformers --share --use-cpu USE_CPU

I just get this error. Seems like the load on CPU is too much/memory is too less

TechnologyClassroom commented 1 year ago

How much free RAM do you have?

adityasohoni commented 1 year ago

around 6 GB

JC254 commented 6 months ago

here is the line that works for me fine but i am trying to optimize my performance as it is currently taking a lot of time to generate the outputs. --use-cpu all --precision full --no-half --skip-torch-cuda-test