How to Set Up Automatic1111 Stable Diffusion WebUI on NixOS

May 23, 2024 | Data Science

If you are eager to dive into the world of artificial intelligence and machine learning, setting up the Automatic1111 Stable Diffusion WebUI can feel like venturing into uncharted waters. Fear not! This guide will smoothly navigate you through the setup process for CUDA and ROCm on NixOS, whether you’re using NVIDIA, AMD GPUs, or even Apple silicon. Grab your metaphorical life jacket, and let’s get underway!

Usage

The journey begins with setup. Follow these easy steps:

Setup

bash
git clone https://github.com/virchau13/automatic1111-webui-nix
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
cp automatic1111-webui-nix/*.nix stable-diffusion-webui
cd stable-diffusion-webui
git add *.nix

After you have cloned the necessary repositories, choose the command based on your platform:

Flakes

  • bash nix develop . #cpu – for CPU or Apple silicon
  • nix develop . #cuda – for CUDA
  • nix develop . #rocm – for ROCm

Non-flakes

  • nix-shell --argstr variant CPU – for CPU
  • nix-shell --argstr variant CUDA – for CUDA
  • nix-shell --argstr variant ROCM – for ROCm

Launching the WebUI

bash
cd automatic1111-webui-nix
.webui.sh

After this, be sure to follow the tutorials at the original project for setting up Stable Diffusion, GFPGAN, and other relevant components. If your device is battery-powered, you might want to switch to high performance mode for optimal use.

Is This Completely Pure?

It’s essential to understand that this setup provides a Nix shell for bootstrapping the web UI but is not a completely pure flake. The accompanying .webui.sh script will install several Python packages into a virtual environment (venv), ensuring your system remains untouched.

Troubleshooting

While your journey should now be smooth sailing, obstacles may arise. Here are some troubleshooting tips:

  • If xformers setup fails, run .webui.sh --xformers.
  • In case of an error, consider pulling the latest updates by running git pull from the source repository.
  • If the problem persists, delete the virtual environment with rm -r venv and reinstall everything from scratch. This helps in clearing out outdated packages that may linger.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Credits

The following contributors have made this setup possible:

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Understanding the Code: An Analogy

Imagine you are preparing a delightful feast. First, you gather the necessary ingredients (repositories) and tools (commands), ensuring you have everything you need before you begin cooking (setting up the environment).

Each step, like choosing whether to sauté or bake (selecting between CPU, CUDA, or ROCm), allows you to adapt to the appliances at your disposal. Finally, launching the web UI is akin to inviting guests for dinner; once they arrive, all preparations culminate in a feast of creativity and functionality!

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox