mirror of
https://github.com/virchau13/automatic1111-webui-nix.git
synced 2024-11-25 21:36:10 +03:00
feat: add CPU and Apple Silicon support
On Apple silicon, the CPU path is still hardware accelerated.
This commit is contained in:
parent
4ae1883e37
commit
a2e79fcaf7
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
stable-diffusion-webui
|
38
README.md
38
README.md
@ -1,17 +1,39 @@
|
|||||||
# [AUTOMATIC1111/stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) for CUDA and ROCm on NixOS
|
# [AUTOMATIC1111/stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) for CUDA and ROCm on NixOS
|
||||||
|
|
||||||
This is literally just a `shell.nix`/`flake.nix` for stable-diffusion-webui that also enables CUDA/ROCm on NixOS.
|
This is literally just a `shell.nix`/`flake.nix` for stable-diffusion-webui that also enables CUDA/ROCm on NixOS.
|
||||||
This supports both NVIDIA GPUs (using CUDA) and AMD GPUs (using ROCm).
|
This supports NVIDIA GPUs (using CUDA), AMD GPUs (using ROCm), and CPU compute (including Apple silicon).
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
### Setup
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
|
|
||||||
git clone https://github.com/virchau13/automatic1111-webui-nix
|
git clone https://github.com/virchau13/automatic1111-webui-nix
|
||||||
cp automatic1111-webui-nix/*.nix stable-diffusion-webui/
|
cd automatic1111-webui-nix
|
||||||
cd stable-diffusion-webui
|
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
|
||||||
git add *.nix
|
```
|
||||||
nix develop # or `nix-shell` if you're not using flakes
|
|
||||||
# just use `./webui.sh` to run it, it'll install all the rest automatically
|
### Flakes
|
||||||
|
|
||||||
|
```bash
|
||||||
|
nix develop # CPU or Apple silicon
|
||||||
|
nix develop .#cuda # CUDA
|
||||||
|
nix develop .#rocm # ROCm
|
||||||
|
```
|
||||||
|
|
||||||
|
### Non-flakes
|
||||||
|
|
||||||
|
```bash
|
||||||
|
nix-shell # CPU
|
||||||
|
nix-shell --argstr variant CUDA # CUDA
|
||||||
|
nix-shell --argstr variant ROCM # ROCm
|
||||||
|
```
|
||||||
|
|
||||||
|
### Launching webui
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd automatic1111-webui-nix
|
||||||
|
./webui.sh
|
||||||
# follow the tutorials at the original project for setting up Stable Diffusion / GFPGAN / whatever
|
# follow the tutorials at the original project for setting up Stable Diffusion / GFPGAN / whatever
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -22,7 +44,6 @@ You might want to switch to high performance mode on battery-powered devices.
|
|||||||
This is just a Nix shell for bootstrapping the web UI, not an actual pure flake; the `./webui.sh` will still install
|
This is just a Nix shell for bootstrapping the web UI, not an actual pure flake; the `./webui.sh` will still install
|
||||||
a bunch of Python packages (into a venv, so not polluting your system) when you run it.
|
a bunch of Python packages (into a venv, so not polluting your system) when you run it.
|
||||||
|
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
### xformers
|
### xformers
|
||||||
@ -31,4 +52,5 @@ Run `./webui.sh --xformers` to set up xformers. If this command fails, try git p
|
|||||||
## Credits
|
## Credits
|
||||||
- AUTOMATIC1111 for obvious reasons.
|
- AUTOMATIC1111 for obvious reasons.
|
||||||
- rprospero for [ROCm support](https://github.com/virchau13/automatic1111-webui-nix/pull/3).
|
- rprospero for [ROCm support](https://github.com/virchau13/automatic1111-webui-nix/pull/3).
|
||||||
|
- Cloudef for [CPU compute / Apple Silicon support](https://github.com/virchau13/automatic1111-webui-nix/pull/10)
|
||||||
- polypoyo for [the original draft of this](https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/4736).
|
- polypoyo for [the original draft of this](https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/4736).
|
||||||
|
11
flake.nix
11
flake.nix
@ -6,17 +6,16 @@
|
|||||||
flake-utils.url = github:numtide/flake-utils;
|
flake-utils.url = github:numtide/flake-utils;
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils }: let
|
outputs = { self, nixpkgs, flake-utils }:
|
||||||
isLinux = system: builtins.match ".*linux.*" system != null;
|
flake-utils.lib.eachSystem flake-utils.lib.defaultSystems (system: let
|
||||||
linuxSystems = builtins.filter isLinux flake-utils.lib.defaultSystems;
|
|
||||||
in flake-utils.lib.eachSystem linuxSystems (system: let
|
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
config.allowUnfree = true;
|
config.allowUnfree = true;
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
devShells.default = import ./impl.nix {inherit pkgs;};
|
devShells.default = import ./impl.nix { inherit pkgs; variant = "CPU"; };
|
||||||
devShells.rocm = import ./impl.nix {inherit pkgs; isCUDA=false;};
|
devShells.cuda = import ./impl.nix { inherit pkgs; variant = "CUDA"; };
|
||||||
|
devShells.rocm = import ./impl.nix { inherit pkgs; variant = "ROCM"; };
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
12
impl.nix
12
impl.nix
@ -1,8 +1,8 @@
|
|||||||
{ pkgs, isCUDA ? true, ... }:
|
{ pkgs, variant ? "CUDA", ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
hardware_deps = with pkgs;
|
hardware_deps = with pkgs;
|
||||||
if isCUDA then [
|
if variant == "CUDA" then [
|
||||||
cudatoolkit
|
cudatoolkit
|
||||||
linuxPackages.nvidia_x11
|
linuxPackages.nvidia_x11
|
||||||
xorg.libXi
|
xorg.libXi
|
||||||
@ -16,10 +16,10 @@ let
|
|||||||
|
|
||||||
# for xformers
|
# for xformers
|
||||||
gcc
|
gcc
|
||||||
] else [
|
] else if variant == "ROCM" then [
|
||||||
rocm-runtime
|
rocm-runtime
|
||||||
pciutils
|
pciutils
|
||||||
];
|
] else [];
|
||||||
|
|
||||||
in
|
in
|
||||||
pkgs.mkShell rec {
|
pkgs.mkShell rec {
|
||||||
@ -38,6 +38,6 @@ pkgs.mkShell rec {
|
|||||||
glib
|
glib
|
||||||
];
|
];
|
||||||
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
|
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
|
||||||
CUDA_PATH = pkgs.lib.optionalString isCUDA pkgs.cudatoolkit;
|
CUDA_PATH = pkgs.lib.optionalString (variant == "CUDA") pkgs.cudatoolkit;
|
||||||
EXTRA_LDFLAGS = pkgs.lib.optionalString isCUDA "-L${pkgs.linuxPackages.nvidia_x11}/lib";
|
EXTRA_LDFLAGS = pkgs.lib.optionalString (variant == "CUDA") "-L${pkgs.linuxPackages.nvidia_x11}/lib";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user