Introduction to Stable-Diffusion-Nvidia-Docker Project
The Stable-Diffusion-Nvidia-Docker project aims to make the powerful capabilities of Stable Diffusion, a state-of-the-art image generation model, accessible to individuals without extensive coding knowledge. This initiative began to assist an art/design enthusiast friend who wanted to experiment with Stable Diffusion on his own Nvidia GPU-equipped PC. By creating a Docker container, the complex setup is simplified, allowing users to seamlessly access the model's features.
Features and Updates
Web UI with Gradio
The project incorporates a simple web UI, built with Gradio, which wraps around the Stable Diffusion model. This provides an easy-to-use interface for users, enhancing their experience as they generate images. Over time, the project intends to expand this UI to include more functionalities.
Multi-GPU Support
Stable-Diffusion-Nvidia-Docker supports inference on multiple GPUs through a "Data Parallel" approach, enhancing the speed of processing by distributing tasks across multiple GPUs. Although the "Model Parallel" approach was initially proposed, it has since been disabled in favor of "Data Parallel" for better parallelism and efficiency.
Stable Diffusion 2.0
The project now defaults to using Stable Diffusion 2.0, known for generating exquisite images compared to its predecessor. Along with standard features, version 2.0 introduces capabilities such as img2img and image inpainting.
Requirements
To run Stable-Diffusion-Nvidia-Docker, users need:
- Operating System: Ubuntu (tested on 20.04) or Windows (tested on Windows 10 21H2)
- An Nvidia GPU with at least 6GB of vRAM
- Free disk space exceeding 2.8GB
- Docker and Nvidia-Docker installed
- A HuggingFace account
Installation
The installation process involves ensuring Docker and Nvidia-Docker are installed on the machine. Windows users may need to perform additional steps such as installing WSL/Ubuntu and updating Nvidia drivers. The pre-built Docker image nicklucche/stable-diffusion
simplifies the setup, requiring just a few commands to initiate and run the model.
Users can start the Stable Diffusion Docker container with:
docker run --name stable-diffusion --pull=always --gpus all -it -p 7860:7860 nicklucche/stable-diffusion
After initialization, the model can be accessed through a local web browser at the address: http://localhost:7860/.
Advanced Configurations
Data Parallelism
For multi-GPU setups, the project supports running the model in a Data Parallel fashion, which replicates the model across GPUs to generate images concurrently. This setup can be controlled using environment variables to specify which GPUs to utilize.
Model Versions
The default model used is stabilityai/stable-diffusion-2-base
, with the flexibility of switching to other compatible models from the HuggingFace repository.
Example Outputs
The project repository showcases various sample images generated using Stable Diffusion, demonstrating its robust capabilities in transforming text input into visual art. These samples illustrate the impact of different parameters, such as guidance_scale
, on the resulting images.
Future Enhancements
To further improve the project, several features are on the wishlist:
- Support for additional input modalities
- Enhanced features like depth-based generation and upscaling
- Optimizing memory usage for larger image generation
- Better handling of previous user prompts and histories
This ongoing project invites users to explore its potential and contribute to its growth by reporting issues or suggesting improvements.