mirror of
https://github.com/gbtb/nix-stable-diffusion.git
synced 2024-09-11 11:16:15 +03:00
2.7 KiB
2.7 KiB
nix-stable-diffusion
Flake for running SD on NixOS
What's done
- Nix devShell capable of running InvokeAI's and stable-diffusion-webui flavors of SD without need to reach for pip or conda (including AMD ROCM support)
- ...???
- PROFIT
How to use it?
InvokeAI
- Clone repo
- Clone submodule with InvokeAI
- Run
nix develop .#invokeai.{default,nvidia,amd}
, wait for shell to build.#invokeai.default
builds shell which overrides bare minimum required for SD to run.#invokeai.amd
builds shell which overrides torch packages with ROCM-enabled bin versions.#invokeai.nvidia
builds shell with overlay explicitly settingcudaSupport = true
for torch
- Inside InvokeAI's directory, run
python scripts/preload_models.py
to preload models (doesn't include SD weights) - Obtain and place SD weights into
models/ldm/stable-diffusion-v1/model.ckpt
- Run CLI with
python scripts/invoke.py
or GUI withpython scripts/invoke.py --web
- For more detailed instructions consult https://invoke-ai.github.io/InvokeAI/installation/INSTALL_LINUX/
stable-diffusion-webui aka 111AUTOMATIC111 fork
- Clone repo
- Clone submodule with stable-diffusion-webui
- Run
nix develop .#webui.{default,nvidia,amd}
, wait for shell to build.#webui.default
builds shell which overrides bare minimum required for SD to run.#webui.amd
builds shell which overrides torch packages with ROCM-enabled bin versions.#webui.nvidia
builds shell with overlay explicitly settingcudaSupport = true
for torch
- Obtain and place SD weights into
stable-diffusion-webui/models/Stable-diffusion/model.ckpt
- Inside
stable-diffusion-webui/
directory, runpython launch.py
to start web server. It should preload required models from the start. Additional models, such as CLIP, will be loaded before the first actual usage of them.
What's needed to be done
- devShell with CUDA support (should be trivial, but requires volunteer with NVidia GPU)
- Missing packages definitions should be submitted to Nixpkgs
- Investigate ROCM device warning on startup
- Apply patches so that all downloaded models would go into one specific folder
- Should create a PR to pynixify with "skip-errors mode" so that no ugly patches would be necessary
- Shell hooks for initial setup?
- May be this devShell should be itself turned into a package?
- Add additional flavors of SD ?
Acknowledgements
Many many thanks to https://github.com/cript0nauta/pynixify which generated all the boilerplate for missing python packages.
Also thanks to https://github.com/colemickens/stable-diffusion-flake and https://github.com/skogsbrus/stable-diffusion-nix-flake for inspiration and some useful code snippets.