Stable Diffusion commands

Launch options of the AUTOMATIC1111 Stable Diffusion web UI, release 1.10.1: the environment variables read by the launch scripts and the flags passed through COMMANDLINE_ARGS, followed by the prompt syntax and the keyboard shortcuts the project documents. The flags come from the project wiki and were checked against the argument parser of that release; options that no longer do anything have their own table. Settings-page options, API routes and arguments added by third-party extensions are not listed.

176 commands in 12 sections. Checked row by row against AUTOMATIC1111 Stable Diffusion web UI wiki: Command Line Arguments and Settings on . Edited by Jay.

Environment variables 16

ShortcutWhat it does
PYTHONPython executable pathSet it in webui-user.bat or webui-user.sh when the launcher should use one particular interpreter.
VENV_DIRVirtual environment folderThe default folder is venv; a single hyphen as the value skips the virtual environment altogether.
COMMANDLINE_ARGSLaunch arguments for the web UIHolds the flags from the tables below, separated by spaces, when you start through the launch scripts.
IGNORE_CMD_ARGS_ERRORSTolerate unknown argumentsWith any value set, an unrecognised flag no longer stops the program with an error.
REQS_FILERequirements file nameNames the dependency list that launch.py installs; requirements_versions.txt is used when it is unset.
TORCH_COMMANDPyTorch install commandOverrides the pip line the launcher uses to install torch.
TORCH_INDEX_URLPyTorch wheel indexFeeds the default torch install line; it points at the cu121 wheel index unless you change it.
INDEX_URLPackage index for pipHanded to pip as its --index-url value when the launcher installs packages.
XFORMERS_PACKAGExformers package to installPins what --xformers installs; release 1.10.1 falls back to xformers==0.0.23.post1.
GITGit executable pathNames the git binary the launcher calls; without it the plain command git is used.
TRANSFORMERS_CACHETransformers download folderWhere the transformers library stores the CLIP model files it downloads.
CUDA_VISIBLE_DEVICESChoose the GPUOn a multi-GPU machine 1 selects the second card; set it on its own line, not inside COMMANDLINE_ARGS.
SD_WEBUI_LOG_LEVELLog verbosityAccepts any level name of Python's logging module and falls back to INFO.
SD_WEBUI_CACHE_FILECache file locationWithout it the web UI keeps its cache in cache.json at the top of the install folder.
SD_WEBUI_RESTARTRestart support markerSet by the launcher scripts, not by you, to signal that the restart function is available.
SD_WEBUI_RESTARTINGRestart-in-progress flagInternal value: 1 suppresses the automatic browser launch during a restart, 0 allows it.

Launch script lines 6

ShortcutWhat it does
set VARNAME=VALUESet a variable on WindowsGoes in webui-user.bat, the file the wiki recommends for variables on Windows.
export VARNAME="VALUE"Set a variable on LinuxGoes in webui-user.sh; the value is wrapped in double quotes.
set COMMANDLINE_ARGS=--xformers --skip-torch-cuda-test --no-half-vae --api --ckpt-dir A:\\stable-diffusion-checkpointsExample flag line for WindowsThe wiki's sample for webui-user.bat: flags follow the equals sign, separated by spaces.
set CUDA_VISIBLE_DEVICES=0Pin the web UI to one GPUAdd it as a separate line in webui-user.bat; 1 would pick the secondary card.
--use-cpu all --precision full --no-half --skip-torch-cuda-testRun on the CPU onlyAll four flags are needed together; generation is very slow and there is no fp16 path.
--gradio-auth username:passwordProtect a shared UI with a loginMeant to accompany --share; more name and password pairs can follow after commas.

Model and data paths 29

ShortcutWhat it does
--data-dirBase folder for user dataThe wiki lists ./ as the default, meaning the install folder.
--models-dirBase folder for modelsTakes precedence over --data-dir for where model files are kept.
--configModel config filePoints at the YAML file from which the model is built.
--ckptCheckpoint to load at startupThe file is also added to the checkpoint list shown in the UI.
--ckpt-dirCheckpoint folderTakes the location of a folder holding Stable Diffusion checkpoint files.
--no-download-sd-modelSkip the default model downloadStops the launcher from fetching the SD1.5 checkpoint when it finds no model.
--do-not-download-clipSkip the CLIP downloadApplies even when the loaded checkpoint does not contain a CLIP model.
--vae-dirVAE folderTakes the folder where your separate VAE files are kept.
--vae-pathForce one VAE checkpointUsing it switches off every VAE-related setting in the UI.
--gfpgan-dirGFPGAN directory
--gfpgan-modelGFPGAN model file name
--codeformer-models-pathCodeFormer model folderDefaults to the Codeformer subfolder of the models directory.
--gfpgan-models-pathGFPGAN model folderDefaults to the GFPGAN subfolder of the models directory.
--esrgan-models-pathESRGAN model folderDefaults to the ESRGAN subfolder of the models directory.
--bsrgan-models-pathBSRGAN model folderDefaults to the BSRGAN subfolder of the models directory.
--realesrgan-models-pathRealESRGAN model folderDefaults to the RealESRGAN subfolder of the models directory.
--scunet-models-pathScuNET model folderDefaults to the ScuNET subfolder of the models directory.
--swinir-models-pathSwinIR model folderHolds SwinIR and SwinIR v2 files; defaults to the SwinIR subfolder of the models directory.
--ldsr-models-pathLDSR model folderDefaults to the LDSR subfolder of the models directory.
--dat-models-pathDAT model folderDefaults to the DAT subfolder of the models directory.
--lora-dirLoRA folderDefaults to the Lora subfolder of the models directory.
--clip-models-pathCLIP model folderUnset by default, unlike the upscaler folders in this table.
--embeddings-dirTextual inversion embeddings folderLooks in the folder named embeddings unless you give another location.
--textual-inversion-templates-dirTextual inversion template folderDefaults to textual_inversion_templates in the install folder.
--hypernetwork-dirHypernetwork folderDefaults to the hypernetworks subfolder of the models directory.
--localizations-dirLocalization files folderDefaults to localizations/ in the install folder.
--styles-fileStyles file locationAccepts a file name or a wildcard and may be repeated; styles.csv is the default.
--ui-config-fileUI configuration fileRead in place of the default ui-config.json.
--ui-settings-fileSettings fileUsed in place of config.json for everything saved from the Settings page.

Network access and API 23

ShortcutWhat it does
--shareCreate a public Gradio linkReturns an xxx.app.gradio address; the wiki calls this the intended way to run in Colab.
--listenAccept connections from the networkBinds the server to 0.0.0.0 so other computers on the LAN can open the UI.
--portServer portDefaults to 7860 when free; ports below 1024 need root or administrator rights.
--server-nameServer hostname
--subpathServe under a URL subpathMeant for running the UI behind a reverse proxy.
--gradio-authRequire a login for the UITakes username:password, or several pairs separated by commas.
--gradio-auth-pathRead UI logins from a fileThe file uses the same user:password format as --gradio-auth.
--apiEnable the APIStarts the API alongside the web interface; use --nowebui for the API alone.
--api-authRequire a login for the APISame username:password syntax as the UI login, with commas between several accounts.
--api-logLog API requestsEvery request made to the API is written to the log.
--nowebuiRun in API-only modeHeadless mode; --skip-load-model-at-start only has an effect together with it.
--api-server-stopAllow stopping the server by APIOpens the stop, restart and kill routes of the API.
--cors-allow-originsAllowed CORS originsA comma-separated list with no spaces between the origins.
--cors-allow-origins-regexAllowed CORS origins by regexOne regular expression instead of a list of origins.
--tls-keyfileTLS private key fileHTTPS works only when --tls-certfile is supplied as well.
--tls-certfileTLS certificate fileHas to be paired with --tls-keyfile before TLS is fully on.
--disable-tls-verifyAllow self-signed certificatesTurns off certificate verification so that a self-signed pair can be used.
--gradio-allowed-pathLet Gradio serve another folderExtends Gradio's allowed_paths so that files in that folder can be served.
--no-gradio-queueDisable the Gradio queueThe page then talks to the server over plain HTTP requests rather than websockets, as early versions did.
--timeout-keep-aliveKeep-alive timeoutSets uvicorn's timeout_keep_alive value, 30 by default.
--ngrokTunnel through ngrokTakes your ngrok authtoken; an alternative to --share.
--ngrok-optionsExtra ngrok optionsA JSON object, for example with basic_auth or oauth_provider keys.
--gradio-debugStart Gradio in debug modeLaunches Gradio with its own --debug option.

Interface and security 20

ShortcutWhat it does
--autolaunchOpen the browser on launchOpens the UI address in the system's default browser once the server is up.
--themeForce light or dark themeWithout it the UI follows the browser's theme.
--use-textbox-seedSeed as a plain text boxLoses the up/down stepper but lets you type very long seed values.
--no-progressbar-hidingKeep Gradio's progress bar visibleIt is hidden by default because it slows generation when the browser uses hardware acceleration.
--hide-ui-dir-configHide folder settings in the UIRemoves the directory configuration fields from the web interface.
--freeze-settingsLock all settingsNothing on the Settings page can be edited while it is set.
--freeze-settings-in-sectionsLock chosen settings sectionsTakes a comma-delimited list of section names such as saving-images,upscaling.
--freeze-specific-settingsLock individual settingsTakes setting names as found in config.json, for example samples_save,samples_format.
--allow-codeAllow custom script executionOff by default; turn it on only when scripts entered in the web UI should be allowed to run.
--enable-insecure-extension-accessKeep the Extensions tab enabledKeeps extension installation available even when other options would switch the tab off.
--disable-safe-unpickleSkip the malicious-code checkStops scanning PyTorch model files for malicious code when they are loaded.
--administratorAdministrator privileges
--disable-all-extensionsDisable all extensionsNeither built-in nor installed extensions run, whatever the Settings say.
--disable-extra-extensionsDisable non-built-in extensionsOnly the extensions shipped with the web UI keep running.
--ui-debug-modeStart the UI without a modelSkips model loading so the interface comes up quickly, for work on the UI itself.
--unix-filenames-sanitizationUnix-style file name rulesOnly the slash is stripped from file names, which can clash with your browser or file system.
--filenames-max-lengthMaximum image file name lengthLonger names are cut off; the default is 128 characters, and raising it may upset the file system.
--no-prompt-historyTurn off last-prompt recallThe UI stops reading the previous generation's prompt, and params.txt is no longer used.
--disable-console-progressbarsHide console progress barsKeeps the terminal output free of progress bars during generation.
--enable-console-promptsPrint prompts to the consoleKept for compatibility: the 1.10.1 parser only uses it as the default of the matching option in Settings.

Installation and startup 18

ShortcutWhat it does
-h / --helpShow the help textPrints every accepted argument and exits without starting the server.
--exitQuit after installingRuns the install steps and stops before the web UI starts.
--skip-installSkip package installationThe launcher goes straight on without installing its Python packages.
--skip-prepare-environmentSkip environment preparationA launch.py argument that bypasses every preparation step, not just package installation.
--skip-version-checkSkip torch and xformers version check
--skip-python-version-checkSkip the Python version check
--skip-torch-cuda-testSkip the CUDA availability testPart of the CPU-only flag set, where no working CUDA device exists to be tested.
--reinstall-xformersForce reinstall of xformersUse it once for an upgrade, then remove it, or xformers is reinstalled at every start.
--reinstall-torchForce reinstall of torchRemove the flag after the upgrade; left in place it reinstalls torch on each launch.
--update-checkCheck for updates at startupReports whether your commit is behind the current master branch.
--update-all-extensionsUpdate all extensions at startupPulls the newest version of every installed extension each time the program starts.
--loglevelLog levelAccepts the five standard names from DEBUG up to CRITICAL.
--log-startupDetailed startup logA launch.py argument that prints what happens at each stage of startup.
--dump-sysinfoWrite a sysinfo file and quitThe dump is limited: it leaves out extension and option details.
--no-hashingSkip checkpoint hashingTurns off SHA-256 hashing of checkpoints so that they load faster.
--skip-load-model-at-startSkip model load at startOnly has an effect together with --nowebui.
--disable-nan-checkSkip the NaN checkGenerated images and latents are not tested for NaN values; handy in CI without a checkpoint.
--device-idDefault CUDA deviceSelects which GPU to use; exporting CUDA_VISIBLE_DEVICES first may be necessary.

Memory and precision 12

ShortcutWhat it does
--medvramMedium VRAM modeSplits the model into three parts and keeps one in VRAM at a time; the speed cost is small.
--medvram-sdxlMedium VRAM mode for SDXL onlyApplies the --medvram optimization only while an SDXL model is in use.
--lowvramLow VRAM modeGoes further than --medvram by keeping a single unet module in VRAM, which is very slow.
--lowramLoad weights to VRAM, not RAMSends checkpoint weights to video memory during loading rather than to system memory.
--disable-model-loading-ram-optimizationTurn off the model-loading RAM saverSwitches off the optimization that lowers memory use while a model loads.
--no-halfKeep the model in full precisionThe model is not converted to 16-bit floats; part of the CPU-only flag set.
--no-half-vaeKeep the VAE in full precisionLeaves only the VAE unconverted, while the main model can still use 16-bit floats.
--precisionEvaluation precisionAccepts full, half or autocast; autocast is the default.
--upcast-samplingUpcast samplingA faster, lighter substitute for --no-half that normally gives similar images; pointless when --no-half is also set.
--use-cpuRun chosen modules on the CPUTakes module names such as all, sd, interrogate, gfpgan, esrgan or codeformer.
--use-ipexUse an Intel XPU deviceMakes torch compute on Intel's XPU backend.
--opt-channelslastChannels-last memory formatCan speed up inference, but only on Nvidia cards that have Tensor cores, 16xx or newer.

Cross-attention optimization 13

Since version 1.3.0 the cross-attention optimization can also be chosen in Settings; xFormers still has to be enabled through COMMANDLINE_ARGS.

ShortcutWhat it does
--xformersUse xformers attentionCuts memory use and raises speed, on Nvidia GPUs only.
--force-enable-xformersForce xformers onSkips the compatibility check; the developers ask for no bug reports if it then fails.
--xformers-flash-attentionxformers with Flash AttentionAimed at reproducible results and supported for SD2.x models and variants only.
--opt-sdp-attentionScaled dot product attentionRequires PyTorch 2; per the Optimizations page it can beat xFormers but uses more VRAM.
--opt-sdp-no-mem-attentionDeterministic scaled dot product attentionThe variant that leaves out memory-efficient attention: repeatable images, PyTorch 2 required.
--opt-split-attentionDoggettx split attentionAlready the automatic choice on CUDA systems, so the flag only forces it elsewhere.
--opt-split-attention-invokeaiInvokeAI split attentionThe automatic choice when CUDA is not available.
--opt-split-attention-v1Older split attention (v1)Uses less VRAM than the current version but limits how large a picture you can make.
--opt-sub-quad-attentionSub-quadratic attentionSaves a lot of memory, sometimes at a small speed cost; suggested where xFormers does not work.
--sub-quad-q-chunk-sizeSub-quadratic query chunk sizeTunes the sub-quadratic optimization; the default value is 1024.
--sub-quad-kv-chunk-sizeSub-quadratic KV chunk sizeUnset by default, unlike the query chunk size.
--sub-quad-chunk-thresholdSub-quadratic chunking thresholdGiven as a percentage of VRAM that decides when chunking is used.
--disable-opt-split-attentionDisable attention optimizationForces generation to run with no cross-attention layer optimization at all.

Defunct options 10

The 1.10.1 argument parser still defines these flags, each with a help text saying it does nothing, so an old launch line that contains one keeps working.

ShortcutWhat it does
--show-negative-promptFormer negative prompt switch
--deepdanbooruFormer DeepDanbooru switch
--unload-gfpganFormer GFPGAN unload switch
--gradio-img2img-toolFormer img2img tool choice
--gradio-inpaint-toolFormer inpaint tool choice
--gradio-queueFormer Gradio queue switchAccepted but ignored; --no-gradio-queue is the flag that still changes queue behaviour.
--add-stop-routeFormer stop route switch
--always-batch-cond-uncondFormer cond/uncond batching flagThe behaviour is now an option in the Optimizations section of the Settings page.
--max-batch-countFormer batch count limitSet txt2img/Batch count/maximum and img2img/Batch count/maximum in ui-config.json instead.
--ngrok-regionFormer ngrok region choiceStill described as active on the wiki, but the 1.10.1 argument parser marks it as doing nothing.

Prompt syntax 15

LoRA and hypernetworks are switched on by a tag in angle brackets, lora:filename:multiplier or hypernet:filename:multiplier; LoRA tags do not work in the negative prompt.

ShortcutWhat it does
(word)Increase attentionMultiplies the weight of the enclosed words by 1.1.
((word))Increase attention twiceEach extra pair of parentheses multiplies by 1.1 again, giving 1.21 here.
[word]Decrease attentionDivides the weight by 1.1; square brackets do not accept a number of their own.
(word:1.5)Set an exact attention weightNumbers above 1 strengthen the words and numbers below 1 weaken them; 0.25 is a fourfold cut.
\(word\)Literal parenthesesA backslash before each bracket keeps it as plain text, as in anime_\(character\).
[from:to:when]Switch prompt text mid-samplingStarts with the first text and swaps to the second at the given step, or at a 0–1 fraction of all steps.
[to:when]Add text after a stepThe text joins the prompt only once the given step count has passed.
[from::when]Remove text after a stepNote the double colon: the text is dropped once that many steps are done.
[cow|horse]Alternate words every stepStep 1 uses the first word, step 2 the second, and so on; longer lists loop back to the start.
BREAKStart a new prompt chunkHas to be uppercase; pads out the current 75-token chunk so that later text begins a fresh one.
ANDCombine several promptsWritten in capitals between prompts, it applies Composable Diffusion; each prompt can carry its own weight.
a cat :1.2 AND a dog AND a penguin :2.2Weight combined promptsA colon and a number after a prompt set its weight; 1 is the default and anything under 0.1 barely registers.
|Separate prompt matrix partsWith the Prompt matrix script selected, one image is made for each combination of the parts.
#Comment out prompt textThe rest of that line is ignored and stays out of the PNG info; available since version 1.8.0.
{prompt}Insert the prompt into a stylePlaced in a saved style, it marks the spot where your typed prompt is put.

Prompt and generation keys 7

ShortcutWhat it does
Ctrl+EnterStart or restart generationDuring a run it interrupts first and then starts again; the handler accepts the Mac Command key in place of Ctrl.
Alt+EnterSkip the current imagePresses the Skip button of the current tab; Option is the same key on a Mac.
EscInterrupt generationWorks while a job is running, unless a popup or the image viewer has focus.
Ctrl+UporCmd+UpRaise attention of selected textSelect words in the prompt box first; each press raises their attention weight by one step.
Ctrl+DownorCmd+DownLower attention of selected textThe counterpart of the key above: each press reduces the weight of the selected words.
Alt+LeftMove prompt element leftSwaps the comma-separated element at the cursor with the one before it; a checkbox in Settings turns the keys off.
Alt+RightMove prompt element rightSwaps the comma-separated element at the cursor with the one that follows it.

Inpaint and sketch canvas 7

The zoom and brush-size modifiers act together with the mouse wheel; all canvas keys are defaults that can be reassigned under Canvas Hotkeys in Settings.

ShortcutWhat it does
Alt+ScrollZoom the canvasHold the modifier and turn the mouse wheel over the image; Settings offers Shift or Ctrl instead.
Ctrl+ScrollChange brush sizeTurning the wheel with the modifier held makes the brush larger or smaller.
QShrink the brushMakes the brush smaller with each press; the key can be changed under Canvas Hotkeys in Settings.
WEnlarge the brushThe opposite of Q: every press makes the brush bigger.
FMove the canvasHold it while moving the mouse to pan; in Firefox, switch off search-as-you-type for it to work.
SFullscreen canvas modeEnlarges the picture to fit the screen across the whole width.
RReset zoom and positionReturns the canvas to its original scale and place after zooming or panning.

Notes

The variables that decide whether it launches

COMMANDLINE_ARGS is where every flag below goes when you launch through the scripts, and PYTHON and VENV_DIR point at a specific interpreter and virtual environment when the system default is the wrong one. CUDA_VISIBLE_DEVICES selects the GPU on a multi-card machine; 1 picks the second card, and the wiki says to set it on its own line rather than inside COMMANDLINE_ARGS. TORCH_COMMAND replaces the PyTorch install line, while TORCH_INDEX_URL changes only the wheel index that line downloads from.

Where things live

--data-dir moves the base path of all user data off the install path, which is what you want when the install is on a small system drive, and --models-dir separates the multi-gigabyte model files again. --ckpt loads a specific checkpoint at startup and --ckpt-dir names a folder of them; --vae-path forces one VAE and switches off the VAE settings in the UI. --lora-dir and --embeddings-dir can point at folders outside the install.

Network exposure and safety

--listen binds to all interfaces so other machines on the LAN can use the UI, and --port changes the default 7860. --share creates a public Gradio link, convenient for a phone but open to anyone who has the address, so combine it with --gradio-auth or avoid it on a machine with anything sensitive. --allow-code permits custom script execution from the UI and should stay off on a shared host. --freeze-settings locks the Settings page for a UI several people use.

Where the wiki and release 1.10.1 disagree

The wiki table is edited by hand and trails the code in a few places. --ngrok-region is still described there as active, but the argument parser of 1.10.1 says it does nothing, so it is listed with the defunct options here. The wiki rows for --tests and --no-tests have no counterpart in the 1.10.1 parser and were left out. The variable the wiki spells SD_WEBUI_RESTAR is exported by the launch scripts as SD_WEBUI_RESTART. In the other direction, --skip-prepare-environment exists in the parser but not on the wiki.

Prompt syntax and keys

Attention weights are written as (word:1.5), and Ctrl + Up or Ctrl + Down writes them for you on the selected text. Plain (word) and [word] stand for a factor of 1.1 up or down. A LoRA is enabled with a tag of the form <lora:filename:multiplier>; the wiki notes that such tags are removed from the prompt after loading, so prompt editing such as [from:to:when] cannot be applied to them.

Questions

Where do I put these --flags?

In the COMMANDLINE_ARGS line of webui-user.bat or webui-user.sh, separated by spaces, or on the command line if you launch launch.py directly.

How do I make the WebUI use my second GPU?

Set CUDA_VISIBLE_DEVICES=1 before launching, as its own line in webui-user.bat or webui-user.sh rather than inside COMMANDLINE_ARGS. The first GPU is 0. The --device-id flag is the alternative the wiki names.

Is --share safe?

It publishes the UI through a public Gradio link. Use it only with a login, for example --gradio-auth username:password, and prefer --listen on a trusted LAN.

My install drive is full — how do I move the models?

Set --models-dir to a folder on another drive, or --data-dir to move the base path of all user data. When both are given, --models-dir wins for the models.

Can the web UI run without a GPU?

Yes, but very slowly. The wiki requires four flags together: --use-cpu all --precision full --no-half --skip-torch-cuda-test.

Which flag helps when the graphics card runs out of VRAM?

Start with --medvram, which keeps one part of the model in VRAM at a time for a small speed cost. --lowvram goes further and is very slow, and --medvram-sdxl applies the first one only to SDXL models.

How do I change the weight of a word without typing the brackets?

Select the word in the prompt box and press Ctrl + Up or Ctrl + Down; on macOS the README gives Command with the same arrow keys.

Sources and checks

5 more source pages

Every row on this page was matched to a line in the documentation above on . A binding that could not be found there is not listed.

2 rows from the earlier version of this page were removed in that check: duplicates, and bindings the documentation does not list or lists differently.

Found a wrong or missing key? Tell us and it gets checked against the source. How we verify describes the process and its limits.