Created
September 14, 2022 15:58
-
-
Save jammus/02f118f4edef9ab3435edf4fd5515651 to your computer and use it in GitHub Desktop.
nix shell for Stable Diffusion (https://github.com/AUTOMATIC1111/stable-diffusion-webui)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import <nixpkgs> {}}: | |
with pkgs; | |
let | |
pythonPackages = python310Packages; | |
nixGLSrc = builtins.fetchGit { | |
url = "https://github.com/guibou/nixGL"; | |
rev = "7165ffbccbd2cf4379b6cd6d2edd1620a427e5ae"; | |
}; | |
nixGLDefault = (pkgs.callPackage nixGLSrc {}).auto.nixGLDefault; | |
nvidiaPackages = pkgs: | |
with pkgs; [ | |
cudaPackages_10_2.cudatoolkit | |
cudaPackages.cudnn | |
nixGLDefault | |
]; | |
requiredPackags = [ | |
python310 | |
git | |
stdenv | |
glib | |
pythonPackages.venvShellHook | |
]; | |
in pkgs.mkShell rec { | |
name = "Imagine.nvim-StableDiffusion"; | |
venvDir = ".venv"; | |
#nrizq2w7q86fgpbmcx178vv5s4hxdlfa-hello.dr Required for building C extensions | |
CUDA_PATH = "${cudaPackages_10_2.cudatoolkit}"; | |
LD_LIBRARY_PATH = | |
"${cudaPackages_10_2.cudatoolkit}/lib:${cudaPackages.cudnn}/lib:${cudaPackages_10_2.cudatoolkit.lib}/lib:${zlib}/lib:${stdenv.cc.cc.lib}/lib:/run/opengl-driver/lib:/run/opengl-driver-32/lib:/usr/lib:/usr/lib32:/run/opengl-driver/lib:/run/opengl-driver-32/lib:/usr/lib:/usr/lib32:${pkgs.glib.out}/lib:$LD_LIBRARY_PATH"; | |
buildInputs = requiredPackags ++ (nvidiaPackages pkgs); | |
# Run this command, only after creating the virtual environment | |
postVenvCreation = '' | |
export LD_LIBRARY_PATH=$(nixGL printenv LD_LIBRARY_PATH):$LD_LIBRARY_PATH | |
unset SOURCE_DATE_EPOCH | |
pip install -r requirements.txt --no-cache-dir --prefer-binary | |
pip install -e . | |
pip install -r repositories/CodeFormer/requirements.txt --prefer-binary | |
pip install -r repositories/CodeFormer/requirements.txt --prefer-binary | |
''; | |
# Now we can execute any commands within the virtual environment. | |
# This is optional and can be left out to run pip manually. | |
postShellHook = '' | |
# allow pip to install wheels | |
unset SOURCE_DATE_EPOCH | |
''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! Pasting the instructions in your comment here for convenience and archival purposes: