From 20256167c33db9c6b762a5bcf0b6678de45653d0 Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Wed, 17 Jun 2026 17:24:26 -0500 Subject: cuda support and immich cuda support --- hosts/poweredge/immich.nix | 80 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 18 deletions(-) (limited to 'hosts/poweredge/immich.nix') diff --git a/hosts/poweredge/immich.nix b/hosts/poweredge/immich.nix index 51d7885..24b32c2 100644 --- a/hosts/poweredge/immich.nix +++ b/hosts/poweredge/immich.nix @@ -1,4 +1,6 @@ -{ +{ pkgs, ... }: let + onnxruntimeCuda = pkgs.onnxruntime.override { cudaSupport = true; }; +in { containers.immich = { autoStart = true; privateNetwork = true; @@ -14,30 +16,55 @@ }; # GPU - #allowedDevices = [ - # { node = "/dev/dri/card1"; modifier = "rw"; } - # { node = "/dev/dri/renderD128"; modifier = "rw"; } - #]; - - #bindMounts = { - # "/dev/dri/card1" = { - # hostPath = "/dev/dri/card1"; - # isReadOnly = false; - # }; - # "/dev/dri/renderD128" = { - # hostPath = "/dev/dri/renderD128"; - # isReadOnly = false; - # }; - #}; + allowedDevices = [ + { node = "/dev/nvidia0"; modifier = "rw"; } + { node = "/dev/nvidiactl"; modifier = "rw"; } + { node = "/dev/nvidia-uvm"; modifier = "rw"; } + { node = "/dev/nvidia-uvm-tools"; modifier = "rw"; } + { node = "/dev/nvidia-modeset"; modifier = "rw"; } + ]; + + bindMounts = { + # NVENC/NVDEC - video transcoding + "/dev/nvidia0" = { hostPath = "/dev/nvidia0"; isReadOnly = false; }; + "/dev/nvidiactl" = { hostPath = "/dev/nvidiactl"; isReadOnly = false; }; + # CUDA - required for ML inference + "/dev/nvidia-uvm" = { hostPath = "/dev/nvidia-uvm"; isReadOnly = false; }; + "/dev/nvidia-uvm-tools" = { hostPath = "/dev/nvidia-uvm-tools"; isReadOnly = false; }; + # Modeset - needed by some driver paths + "/dev/nvidia-modeset" = { hostPath = "/dev/nvidia-modeset"; isReadOnly = false; }; + }; config = { lib, pkgs, config, ... }: { # Network networking.interfaces.eth0.useDHCP = true; networking.firewall.allowedTCPPorts = [ 80 ]; # Caddy + # Configure nixpkgs for nvidia/cuda + nixpkgs.config.allowUnfree = true; + nixpkgs.config.cudaSupport = true; + # Immich - services.immich.enable = true; - environment.systemPackages = with pkgs; [ immich immich-cli ]; + services.immich = { + enable = true; + accelerationDevices = [ + "/dev/nvidia0" + "/dev/nvidiactl" + "/dev/nvidia-uvm" + "/dev/nvidia-uvm-tools" + "/dev/nvidia-modeset" + ]; + + # Tell immich-server to use NVENC for transcoding + environment = { + NVIDIA_VISIBLE_DEVICES = "all"; + NVIDIA_DRIVER_CAPABILITIES = "compute,video,utility"; + }; + + # Enable the ML microservice with CUDA + machine-learning.enable = true; + }; + #environment.systemPackages = with pkgs; [ immich immich-cli ]; # Reverse proxy services.caddy = { @@ -47,6 +74,23 @@ ''; }; + # NVIDIA + services.xserver.videoDrivers = [ "nvidia" ]; # xserver.videoDrivers does not imply X + hardware.graphics.enable = true; + hardware.nvidia = { + modesetting.enable = true; # Required + nvidiaSettings = false; # Don't need gui + open = false; + package = config.boot.kernelPackages.nvidiaPackages.legacy_580; # Must match host + }; + + # Packages + environment.systemPackages = with pkgs; [ + immich + immich-cli + config.hardware.nvidia.package # nvidia-smi + ]; + system.stateVersion = "25.11"; }; }; -- cgit v1.2.3