Immich machine learning not working

Hey there! So, I’ve gotten immich working on my tiny server in NixOS, however the machine learning does not work. My config is as follows:

{self,inputs, pkgs, config,...}:{
    services={
        nginx.virtualHosts ={
            "cutedomaint" =  {
                enableACME = true;
                forceSSL = true;
                locations."/" = {
                    proxyPass = "http://localhost:4444";
                    recommendedProxySettings = true;
                    proxyWebsockets = true; # immich might use websockets
                };
                extraConfig="client_max_body_size 0;";
            };
        };
        immich={
            package=pkgs.unstable-small.immich;
            enable=true;
            mediaLocation="/mnt/atlanticpool/Immich/Library/";
            openFirewall=true;
            port=4444;
            host="127.0.0.1";
            settings."logging"= {
                enabled = true;
                level= "debug";
            };
            machine-learning.enable=true;
            settings.server.externalDomain="https://cutedomain";
                database.createDB = false;
        };
    };
}


with logs from both the machine learning server and immich itself provided as follows
machine learning immich-server . Do keep in mind that i am not using hardware acceleration, just normal old cpu!
Thanks in advance!

I’m not entirely sure it’s the same error, but I fixed my machine learning problem by adding the following:

  services.immich.machine-learning.environment = {
    HF_XET_CACHE = "/var/cache/immich/huggingface-xet";
  };
  # not sure how essential this second part is, but just in case...
  users.users.immich = {
    home = "/var/lib/immich";
    createHome = true;
  };

Sadly I forgot to note where I got this trick from, but it fixed it (old cpu as well). Essentially, it tells the machine learning where to download the model to. I think the error in your logs about /var/empty is what I was seeing.

As a side note, you can make your config a bit more resilient by modifying your nginx config like this:

proxyPass = "http://localhost:${toString config.services.immich.port}";

Hope this helps!

1 Like

It did help! Thank you very much!

It’s a regression in a dependency of immich. Context here: nixos/immich-machine-learning: huggingface-hub permissions error · Issue #418799 · NixOS/nixpkgs · GitHub

It will likely be fixed in a couple of versions, I’d really recommend subscribing to that issue and removing this hack when it’s fixed. Hell, you can probably remove the hack now, looks like it’s only required for the initial download.

1 Like