run-stable-diffusion-locally-gpu-cpu.md
Want to generate AI images on your own PC, for free, without relying on a paid cloud service? This guide walks through the full setup — from a clean machine to your first generated image — using Stability Matrix as the installer/manager and Stable Diffusion WebUI reForge as the actual generation interface. It works whether you're running on a GPU or just a CPU.
- A Windows PC (GPU or CPU — either works, GPU is just much faster)
- A free GitHub account
- A free Civitai account
- A free Hugging Face account
- About 15–20 minutes for setup, plus download time depending on your internet speed
Download and install the latest version of Python from the official site:
👉 https://www.python.org/downloads/
Just run the installer with default settings — Stability Matrix will handle the rest.
Stability Matrix is a free, open-source package manager for Stable Diffusion UIs. It handles installation, updates, and model management so you don't have to fight with dependencies manually.
- Go to the Stability Matrix GitHub repo and download the latest release.
- Having a free GitHub account makes this easier (and is useful if you ever want to browse issues/discussions for troubleshooting).
- Install and launch Stability Matrix.
Inside Stability Matrix:
- Go to the Packages tab.
- Find and install Stable Diffusion WebUI reForge.
- Let it finish downloading and setting up — this can take a few minutes.
To download checkpoints, LoRAs, and VAEs directly inside Stability Matrix, you'll want to connect two free accounts.
- Create a free account at civitai.com.
- Go to your account settings and scroll down to API Keys > Add API key.
- Copy the generated key.
- In Stability Matrix: Settings > Account > Civitai > Connect, and paste the key in.
- Create a free account at huggingface.co.
- Go to Settings > Tokens and create a new token.
- Copy the token.
- In Stability Matrix: Settings > Account > Hugging Face > Connect, and paste the token in.
In Stability Matrix, open the sidebar and go to Model Manager.
For your first setup, keep things simple:
- Filter Base Model by:
SD 1.5,SD Hyper,SD 1.5 LCM— these tend to run more reliably across a wider range of hardware. - Then filter by Model Type to grab a Checkpoint, a LoRA, and a VAE.
Recommended starter checkpoint: EpiCRealism XL — beginner-friendly and produces solid results out of the box.
Once you're comfortable with the basics, feel free to explore other base models and model types — but the above is enough to get your first image generated.
- Go back to Packages in Stability Matrix.
- Before launching, click the gear/cog icon next to the Launch button.
- Enable either Force GPU or Force CPU, depending on which you plan to use primarily.
- GPU: generation typically takes a few seconds per image (depending on your card).
- CPU: works, but noticeably slower — expect minutes per image.
- Click Launch.
If the WebUI doesn't open automatically in your browser, look for this line in the launch console:
Running on local URL: http://127.0.0.1:7860
Click that link, or manually type http://127.0.0.1:7860 into your browser's address bar.
Once the WebUI is open in your browser:
- Checkpoint: set to
EpiCRealism XL(or whichever you downloaded). - VAE (optional): set to whichever VAE you downloaded (e.g.
Voidnoise VAE). - Width / Height: try
512x768for portrait, or768x512for landscape. - Batch count: how many images to generate per run — keep this at
1for your first test (setting it to2generates 2 images from the same prompt). - Sampling method:
DPM++ 2Mworks well as a default. Leave everything else at default settings for now. - Prompt: write a detailed description of what you want to generate.
- Prompt guide: promptteardown.com
- Negative prompt: describe what you don't want in the image.
- Negative prompt guide: ltx.io/blog/negative-prompts
- Click Generate.
Generation should take a few seconds (GPU) or a couple minutes (CPU). That's it — your first AI-generated image, made entirely on your own PC, for free.
This means your system's virtual memory (paging file) isn't large enough for the task.
Fix:
- Press
Win + R, typesysdm.cpl, hit Enter. - Go to the Advanced tab.
- Under Performance, click Settings.
- In the new window, go to the Advanced tab.
- Under Virtual Memory, click Change.
- Uncheck "Automatically manage paging file size for all drives."
- Select Custom size and enter values in MB — e.g., Initial size:
16384, Maximum size:32768(for 16GB/32GB setups). - Click Set, then OK, and restart your computer.
Fix: Add the --disable-nan-check launch argument. This stops the WebUI from crashing on certain number-related errors during generation (note: it can occasionally result in blank/black image output instead of a crash).
- Open
webui-user.batin a text editor (Notepad works fine). By default it's located at:C:\Stability Matrix\Packages\Stable Diffusion WebUI reForge - Find the line starting with
set COMMANDLINE_ARGS=. - Add the flag so it looks like:
set COMMANDLINE_ARGS=--disable-nan-check - Save the file and restart the WebUI.
The console crashes immediately with a traceback mentioning missing DLLs (e.g. c10.dll).
Cause: Your system is missing runtime components required by PyTorch and its C++ backend.
Fix: Download and install the latest Visual C++ Redistributable from Microsoft: 👉 learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist
The terminal starts up fine, but http://127.0.0.1:7860 shows a blank page or times out.
Cause: A local proxy, VPN, or firewall is intercepting traffic to the local address.
Fix:
- Temporarily disable any active VPNs, proxy tools, or aggressive ad-blocker extensions.
- Or force a new port by adding
--port 7861to your launch arguments and navigating tohttp://127.0.0.1:7861instead.
This setup should get you from zero to your first locally-generated image. If you run into an error not covered here, a search on GitHub Issues (for reForge or Stability Matrix) or the Stable Diffusion subreddit will usually turn up a fix — these are common enough tools that most errors have already been solved by someone else.
Happy generating!