Skip to content

Commit

Permalink
Deduplicate unsafe optimizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
kurnevsky committed Dec 12, 2024
1 parent c3f47ae commit 683df92
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
15 changes: 6 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,12 @@
})
];
llamaOverride = pkgs: llama:
llama.overrideAttrs (old: {
postInstall = (old.postInstall or "") + ''
find $out/bin -type f ! -wholename '*/llama*' -exec ${pkgs.util-linux}/bin/rename "" 'llama-' {} \;
'';
NIX_CFLAGS_COMPILE = [ "-O3" "-march=native" "-mtune=native" ];
NIX_ENFORCE_NO_NATIVE = false;
preferLocalBuild = true;
allowSubstitutes = false;
});
import ./modules/with-native-optimizations.nix (llama.overrideAttrs
(old: {
postInstall = (old.postInstall or "") + ''
find $out/bin -type f ! -wholename '*/llama*' -exec ${pkgs.util-linux}/bin/rename "" 'llama-' {} \;
'';
}));
llamaDefault = { pkgs, ... }: {
environment.systemPackages = [
(llamaOverride pkgs inputs.llama-cpp.packages.${pkgs.system}.default)
Expand Down
9 changes: 5 additions & 4 deletions machines/pc/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@

environment.systemPackages = with pkgs; [
radeontop
(pkgs.callPackage ../../modules/stable-diffusion-cpp.nix {
useRocm = true;
gpuTargets = "gfx1100";
})
(import ../../modules/with-native-optimizations.nix
(pkgs.callPackage ../../modules/stable-diffusion-cpp.nix {
useRocm = true;
gpuTargets = "gfx1100";
}))
((python3.withPackages (pkgs:
with pkgs; [
# TODO: broken
Expand Down
5 changes: 0 additions & 5 deletions modules/stable-diffusion-cpp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ stdenv.mkDerivation {
HIP_DEVICE_LIB_PATH = "${rocmPackages.rocm-device-libs}/amdgcn/bitcode";
};

NIX_CFLAGS_COMPILE = [ "-O3" "-march=native" "-mtune=native" ];
NIX_ENFORCE_NO_NATIVE = false;
preferLocalBuild = true;
allowSubstitutes = false;

meta = {
description = "Stable Diffusion in pure C/C++";
homepage = "https://github.com/leejet/stable-diffusion.cpp";
Expand Down
9 changes: 9 additions & 0 deletions modules/with-native-optimizations.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
drv:

drv.overrideAttrs (old: {
pname = old.pname + "-unsafe";
NIX_CFLAGS_COMPILE = [ "-O3" "-march=native" "-mtune=native" ];
NIX_ENFORCE_NO_NATIVE = false;
preferLocalBuild = true;
allowSubstitutes = false;
})

0 comments on commit 683df92

Please sign in to comment.