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.


1. Why do I need a Hugging Face account to run Stable Diffusion locally?

A Hugging Face account is required because Stable Diffusion’s model weights and checkpoints are hosted on the Hugging Face platform. By creating an account, you gain access to download these essential files, which are necessary for running the model on your local machine.

2. I have a GPU with less than 6GB of VRAM. Can I still run Stable Diffusion?

While it’s recommended to have a GPU with at least 6GB of VRAM for optimal performance, you might still be able to run Stable Diffusion on a GPU with less VRAM. However, you may encounter runtime issues or limitations in the size and complexity of the images you can generate. It’s advisable to monitor your GPU’s memory usage to prevent potential crashes.

3. What should I do if I encounter errors or issues while setting up or running Stable Diffusion locally?

First, ensure that you’ve followed all the steps correctly and haven’t missed any. If you’re still facing issues, consider checking the GitHub repository’s “Issues” section, as others might have faced similar problems and solutions might be provided. Additionally, you can also raise a new issue detailing the problem you’re facing, and the community or the repository maintainers might assist you.


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.

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