mirror of
https://github.com/virchau13/automatic1111-webui-nix.git
synced 2024-11-22 14:14:05 +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
|
||||
|
||||
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
|
||||
|
||||
### Setup
|
||||
|
||||
```bash
|
||||
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
|
||||
git clone https://github.com/virchau13/automatic1111-webui-nix
|
||||
cp automatic1111-webui-nix/*.nix stable-diffusion-webui/
|
||||
cd 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
|
||||
cd automatic1111-webui-nix
|
||||
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
|
||||
```
|
||||
|
||||
### 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
|
||||
```
|
||||
|
||||
@ -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
|
||||
a bunch of Python packages (into a venv, so not polluting your system) when you run it.
|
||||
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### xformers
|
||||
@ -31,4 +52,5 @@ Run `./webui.sh --xformers` to set up xformers. If this command fails, try git p
|
||||
## Credits
|
||||
- AUTOMATIC1111 for obvious reasons.
|
||||
- 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).
|
||||
|
11
flake.nix
11
flake.nix
@ -6,17 +6,16 @@
|
||||
flake-utils.url = github:numtide/flake-utils;
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }: let
|
||||
isLinux = system: builtins.match ".*linux.*" system != null;
|
||||
linuxSystems = builtins.filter isLinux flake-utils.lib.defaultSystems;
|
||||
in flake-utils.lib.eachSystem linuxSystems (system: let
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachSystem flake-utils.lib.defaultSystems (system: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
in {
|
||||
devShells.default = import ./impl.nix {inherit pkgs;};
|
||||
devShells.rocm = import ./impl.nix {inherit pkgs; isCUDA=false;};
|
||||
devShells.default = import ./impl.nix { inherit pkgs; variant = "CPU"; };
|
||||
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
|
||||
hardware_deps = with pkgs;
|
||||
if isCUDA then [
|
||||
if variant == "CUDA" then [
|
||||
cudatoolkit
|
||||
linuxPackages.nvidia_x11
|
||||
xorg.libXi
|
||||
@ -16,10 +16,10 @@ let
|
||||
|
||||
# for xformers
|
||||
gcc
|
||||
] else [
|
||||
] else if variant == "ROCM" then [
|
||||
rocm-runtime
|
||||
pciutils
|
||||
];
|
||||
] else [];
|
||||
|
||||
in
|
||||
pkgs.mkShell rec {
|
||||
@ -38,6 +38,6 @@ pkgs.mkShell rec {
|
||||
glib
|
||||
];
|
||||
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
|
||||
CUDA_PATH = pkgs.lib.optionalString isCUDA pkgs.cudatoolkit;
|
||||
EXTRA_LDFLAGS = pkgs.lib.optionalString isCUDA "-L${pkgs.linuxPackages.nvidia_x11}/lib";
|
||||
CUDA_PATH = pkgs.lib.optionalString (variant == "CUDA") pkgs.cudatoolkit;
|
||||
EXTRA_LDFLAGS = pkgs.lib.optionalString (variant == "CUDA") "-L${pkgs.linuxPackages.nvidia_x11}/lib";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user