sif.nix 729 B

123456789101112131415161718192021222324252627
  1. {
  2. lib,
  3. singularity-tools,
  4. llama-cpp,
  5. bashInteractive,
  6. interactive ? false,
  7. }:
  8. let
  9. optionalInt = cond: x: if cond then x else 0;
  10. in
  11. singularity-tools.buildImage rec {
  12. inherit (llama-cpp) name;
  13. contents = [ llama-cpp ] ++ lib.optionals interactive [ bashInteractive ];
  14. # These are excessive (but safe) for most variants. Building singularity
  15. # images requires superuser privileges, so we build them inside a VM in a
  16. # writable image of pre-determined size.
  17. #
  18. # ROCm is currently affected by https://github.com/NixOS/nixpkgs/issues/276846
  19. #
  20. # Expected image sizes:
  21. # - cpu/blas: 150M,
  22. # - cuda, all gencodes: 560M,
  23. diskSize = 4096 + optionalInt llama-cpp.useRocm 16384;
  24. memSize = diskSize;
  25. }