How To Run Stable Diffusion Locally?

If you want to run Stable Diffusion locally, then you have reached the right place. In this article, we have discussed the steps to run it locally on your personal Computer.

Let’s get down to business.

How To Run Stable Diffusion Locally?


You can use your Computer to run Stable Diffusion locally if your GPU has at least 6GB of VRAM. The Stable Diffusion runtime issue may appear if your GPU has insufficient VRAM.

Here are the steps you must follow to run it locally:

I. Create Your Hugging Face Account

  • In order to download it, you must create a Hugging Face account in case you do not have one. Go to their website; on the top right, you will see a “Sign Up” button. Click on it.
  • Now visit the “CompVis” page. Scroll down, and you will find stable-diffusion-v1-4. Click on it. You will be taken to its page.
  • Once you reach the page, go to the files and versions tab. You will find the sd-v1-4.ckpt file, download it. This file is about 4GB big.

II. Visit The GitHub Repository

  • Visit the GitHub repo and clone the repository. Click on the “Code” dropdown and either copy the URL and run the $ git clone <repository URL>  on your command prompt/shell or download the ZIP file. Once the file is downloaded, unzip it. You can check for more GitHub commands here.
  • Now, navigate to the folder: stable-diffusion-main/models/ldm. Create a folder “stable-diffusion-v1”. Change the sd-v1-4.ckpt file to model.ckpt, and copy it into the stable-diffusion-v1 folder.
  • You will find a YAML file called environment.yaml. Open that file on your Notepad. There, you will see a line saying dependencies: to that, put – git.

III. Download Miniconda

  • Now, download Miniconda to your system. Check the compatibility with your operating system, and read the system requirements on the first page. You will find different installer links for other operating systems, such as Windows, macOS, and Linux.
  • Preferably, choose Miniconda 3. The installer comes in two forms: Miniconda, which is based on Python 2, and Miniconda 3, which is based on Python 3.
  • Once downloaded, remove the check from Register Miniconda as the system Python 3.9.

IV. Run And Generate An Image On The Prompt

  • Python and the Conda package manager are included in these Miniconda installers. The conda command can be used to install any further packages, set up environments, etc.
  • Here is how you can install the packages:
$ conda install numpy
$ conda create -n py3k anaconda python=3
  • To update conda, do the following:
$ conda update conda
  • Now, we shall use commands to generate images locally. Launch the Anaconda prompt, which is Miniconda 3.
  • Write cd in the prompt. Copy and paste the folder path after cd. Ensure you are in the stable-diffusion-main folder.
  • After this, type the following command:
conda env create -f environment.yaml.
  • Then, run this:
conda activate ldm.
  • Once the above steps are done, to generate the image, use this command:
python scripts/ --prompt "Enter The Text Prompt To Generate The Image" --H 512 --W 512 --seed 27 --n_iter 2 --ddim_steps 50.

For Example:

python scripts/ --prompt "Darth Vader celebrating his birthday party with Luke and Leia" --H 512 --W 512 --seed 27 --n_iter 2 --ddim_steps 50.

Be as creative as you can be.

  • In case of an error, run this command instead:
python optimizedSD/ --prompt "Darth Vader celebrating his birthday party with Luke and Leia" --H 512 --W 512 --seed 27 --n_iter 1 --ddim_steps 50.


So, it can look a tad bit complicated, but once you get a grip, you can easily generate images on Stable Diffusion locally on your system without using any website.

stable diffusion

Read more such articles: Midjourney Vs. NightCafe | Which One Is Good?