Skip to content

Commit ad97e85

Browse files

File tree

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
4+
flake-utils.url = "github:numtide/flake-utils";
5+
};
6+
outputs = { self, nixpkgs, flake-utils }:
7+
flake-utils.lib.eachDefaultSystem (system:
8+
let
9+
name = "stable-diffusion.cpp";
10+
src = ./.;
11+
meta.mainProgram = "sd";
12+
stdenv = (pkgs.stdenvAdapters.keepDebugInfo pkgs.stdenv);
13+
inherit (pkgs.stdenv) isAarch32 isAarch64 isDarwin;
14+
buildInputs = with pkgs; [ boost ];
15+
osSpecific = with pkgs; buildInputs ++ (
16+
if isAarch64 && isDarwin then
17+
with pkgs.darwin.apple_sdk_11_0.frameworks; [
18+
Accelerate
19+
MetalKit
20+
]
21+
else if isAarch32 && isDarwin then
22+
with pkgs.darwin.apple_sdk.frameworks; [
23+
Accelerate
24+
CoreGraphics
25+
CoreVideo
26+
]
27+
else if isDarwin then
28+
with pkgs.darwin.apple_sdk.frameworks; [
29+
Accelerate
30+
CoreGraphics
31+
CoreVideo
32+
]
33+
else
34+
with pkgs; [ openblas ]
35+
);
36+
pkgs = import nixpkgs { inherit system; };
37+
nativeBuildInputs = with pkgs; [ cmake ninja pkg-config git ];
38+
cmakeFlags = [
39+
"-DCMAKE_BUILD_TYPE=RelWithDebInfo"
40+
#"-DCMAKE_BUILD_TYPE=Debug"
41+
#"-DCMAKE_C_FLAGS:STRING=-Og"
42+
#"-DCMAKE_CXX_FLAGS:STRING=-Og"
43+
#"-DCMAKE_C_FLAGS:STRING=-fsanitize=address,undefined"
44+
#"-DCMAKE_CXX_FLAGS:STRING=-fsanitize=address,undefined"
45+
#"-DCMAKE_EXE_LINKER_FLAGS:STRING=-fsanitize=address,undefined"
46+
47+
48+
# does not work
49+
"-DGGML_NATIVE=OFF"
50+
"-DGGML_AVX=ON"
51+
"-DGGML_AVX2=ON"
52+
"-DGGML_FMA=ON"
53+
"-DGGML_F16C=ON"
54+
55+
#"-DBUILD_SHARED_LIBS=ON"
56+
"-DCMAKE_SKIP_BUILD_RPATH=ON"
57+
];
58+
in
59+
{
60+
packages.default = stdenv.mkDerivation {
61+
inherit name src meta nativeBuildInputs;
62+
buildInputs = osSpecific;
63+
};
64+
packages.cuda = stdenv.mkDerivation {
65+
inherit name src meta;
66+
buildInputs = with pkgs; buildInputs ++ [
67+
#cudaPackages.cudatoolkit
68+
cudaPackages.cuda_cccl # <nv/target>
69+
70+
# A temporary hack for reducing the closure size, remove once cudaPackages
71+
# have stopped using lndir: https://github.com/NixOS/nixpkgs/issues/271792
72+
cudaPackages.cuda_cudart
73+
cudaPackages.libcublas
74+
];
75+
nativeBuildInputs = with pkgs; nativeBuildInputs ++ [
76+
cudaPackages.cuda_nvcc
77+
autoAddDriverRunpath
78+
];
79+
cmakeFlags = cmakeFlags ++ [
80+
"-DSD_CUDA=ON"
81+
"-DCMAKE_CUDA_ARCHITECTURES=75"
82+
];
83+
};
84+
apps.sd = {
85+
type = "app";
86+
program = "${self.packages.${system}.default}/bin/sd";
87+
};
88+
apps.default = self.apps.${system}.sd;
89+
});
90+
}

src/stable-diffusion.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,8 @@ class StableDiffusionGGML {
943943
pred_type = FLOW_PRED;
944944
if (sd_version_is_wan(version)) {
945945
default_flow_shift = 5.f;
946+
} else if (sd_version_is_ernie_image(version)) {
947+
default_flow_shift = 4.f;
946948
} else {
947949
default_flow_shift = 3.f;
948950
}

0 commit comments

Comments
 (0)