-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ml.nix
34 lines (33 loc) · 1.01 KB
/
ml.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{ config, lib, pkgs, ... }:
let
cfg = config.lun.ml;
virtualisation = config.virtualisation.podman.enable or config.virtualisation.docker.enable;
nvidia = builtins.elem "nvidia" cfg.gpus;
amd = builtins.elem "amd" cfg.gpus;
in
{
options.lun.ml = {
enable = lib.mkEnableOption "Enable ml";
gpus = with lib; mkOption {
type = with types; listOf (enum [ "nvidia" "amd" "intel" ]);
description = "";
default = [ ];
};
};
config = lib.mkIf cfg.enable (lib.mkMerge [
(lib.mkIf (virtualisation && nvidia) {
virtualisation.docker.enableNvidia = true;
virtualisation.podman.enableNvidia = true;
# https://github.com/NixOS/nixpkgs/issues/127146
systemd.enableUnifiedCgroupHierarchy = false;
})
(lib.mkIf (virtualisation && amd) {
# TODO: anything else needed?
hardware.graphics.extraPackages = [
pkgs.rocmPackages.rocm-opencl-icd
pkgs.rocmPackages.rocm-opencl-runtime
pkgs.rocmPackages.rocm-runtime
];
})
]);
}