Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions ct/immich-remote-ml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env bash
_CS_DEFAULT_URL="https://raw.githubusercontent.com/community-scripts/DevScripts/main"
_cs_boot="${COMMUNITY_SCRIPTS_CORE_DIR:-$(dirname "${BASH_SOURCE[0]}")/../../core}/core/build.func"
source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/build.func")

# Copyright (c) 2021-2026 community-scripts ORG
# Author: jwklijnsma (jwklijnsma)
# License: MIT | https://github.com/community-scripts/DevScripts/raw/main/LICENSE
# Source: https://immich.app | https://github.com/immich-app/immich

APP="Immich Remote ML"
var_tags="${var_tags:-photos;ai}"
var_cpu="${var_cpu:-6}"
var_ram="${var_ram:-12288}"
var_disk="${var_disk:-50}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
var_arm64="${var_arm64:-no}" # ROCm and Immich's ROCm ONNX Runtime are amd64-only.
var_unprivileged="${var_unprivileged:-1}"
var_gpu="${var_gpu:-yes}"

header_info "$APP"
variables
color
catch_errors

function update_script() {
header_info
check_container_storage
check_container_resources

local APP_DIR="/opt/immich-remote-ml"
local DATA_DIR="/opt/immich-remote-ml_data"
local ML_SOURCE_DIR="${APP_DIR}/machine-learning"
local VENV_DIR="${DATA_DIR}/venv"

if [[ ! -d "$ML_SOURCE_DIR" ]]; then
msg_error "No Immich Remote ML installation found!"
exit
fi

if check_for_gh_release "immich-remote-ml" "immich-app/immich"; then
msg_info "Stopping Immich Remote ML"
systemctl stop immich-remote-ml
msg_ok "Stopped Immich Remote ML"

set -a
source /etc/default/immich-remote-ml
set +a

CLEAN_INSTALL=1 fetch_and_deploy_gh_release "immich-remote-ml" "immich-app/immich" "tarball" "latest" "$APP_DIR"
UV_PROJECT_ENVIRONMENT="$VENV_DIR" $STD uv sync --project "$ML_SOURCE_DIR" --locked --no-dev --no-install-project --extra "${ML_EXTRA:-cpu}" --python 3.13 --link-mode copy

msg_info "Starting Immich Remote ML"
systemctl start immich-remote-ml
msg_ok "Started Immich Remote ML"
msg_ok "Updated Immich Remote ML successfully!"
fi
exit
}

start
build_container
description

msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW}Immich Machine Learning API is available at:${CL}"
echo -e "${GATEWAY}${BGN}http://${IP}:3003${CL}"
112 changes: 112 additions & 0 deletions install/immich-remote-ml-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/usr/bin/env bash

# Copyright (c) 2021-2026 community-scripts ORG
# Author: jwklijnsma (jwklijnsma)
# License: MIT | https://github.com/community-scripts/DevScripts/raw/main/LICENSE
# Source: https://immich.app | https://github.com/immich-app/immich

source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os

APP_DIR="/opt/immich-remote-ml"
DATA_DIR="/opt/immich-remote-ml_data"
ML_SOURCE_DIR="${APP_DIR}/machine-learning"
VENV_DIR="${DATA_DIR}/venv"
CACHE_DIR="${DATA_DIR}/cache"
HOME_DIR="${DATA_DIR}/home"

if [[ "$(get_os_info id)" != "debian" || "$(get_os_info codename)" != "trixie" ]]; then
msg_error "Immich Remote ML currently requires Debian 13 (Trixie)."
exit 1
fi

if [[ "$(arch_resolve)" != "amd64" ]]; then
msg_error "Immich Remote ML ROCm acceleration currently requires amd64."
exit 1
fi

$STD apt install -y g++ git

PYTHON_VERSION="3.13" setup_uv
setup_hwaccel

fetch_and_deploy_gh_release "immich-remote-ml" "immich-app/immich" "tarball" "latest" "$APP_DIR"

if [[ "${HWACCEL_VENDOR:-none}" == "amd" ]]; then
ML_EXTRA="rocm"
DEVICE="rocm"
$STD apt install -y migraphx miopen-hip
msg_ok "Configured AMD ROCm machine-learning backend"
else
ML_EXTRA="cpu"
DEVICE="cpu"
msg_warn "No AMD ROCm GPU detected; using the CPU machine-learning backend"
fi

mkdir -p "$DATA_DIR" "$CACHE_DIR/jit/comgr" "$CACHE_DIR/hf-cache" "$HOME_DIR" "$VENV_DIR"

cat <<EOF >/etc/default/immich-remote-ml
ML_EXTRA=$ML_EXTRA
DEVICE=$DEVICE
EOF

UV_PROJECT_ENVIRONMENT="$VENV_DIR" $STD uv sync --project "$ML_SOURCE_DIR" --locked --no-dev --no-install-project --extra "$ML_EXTRA" --python 3.13 --link-mode copy

msg_info "Creating Immich Remote ML service"
cat <<EOF >/etc/systemd/system/immich-remote-ml.service
[Unit]
Description=Immich Remote Machine Learning
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
WorkingDirectory=$ML_SOURCE_DIR
EnvironmentFile=-/etc/default/immich-remote-ml
Environment=HOME=$HOME_DIR
Environment=PATH=$VENV_DIR/bin:/opt/rocm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Environment=IMMICH_HOST=0.0.0.0
Environment=IMMICH_PORT=3003
Environment=MACHINE_LEARNING_CACHE_FOLDER=$CACHE_DIR
Environment=MACHINE_LEARNING_MODEL_REVISION=v2
Environment=HF_HOME=$CACHE_DIR/hf-cache
Environment=AMD_COMGR_CACHE_DIR=$CACHE_DIR/jit/comgr
ExecStart=$VENV_DIR/bin/python -m immich_ml
Restart=on-failure
RestartSec=10
TimeoutStartSec=300
TimeoutStopSec=30
KillMode=control-group
PrivateTmp=true
PrivateDevices=false
ProtectSystem=strict
ProtectHome=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
NoNewPrivileges=true
RestrictSUIDSGID=true
LockPersonality=true
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
ReadWritePaths=$DATA_DIR

[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now immich-remote-ml.service
msg_ok "Created Immich Remote ML service"

if ! systemctl is-active --quiet immich-remote-ml.service; then
journalctl -u immich-remote-ml.service -n 50 --no-pager
msg_error "Immich Remote ML failed to start"
exit 1
fi

motd_ssh
customize
cleanup_lxc
40 changes: 40 additions & 0 deletions json/immich-remote-ml.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "Immich Remote ML",
"slug": "immich-remote-ml",
"categories": [20],
"date_created": "2026-11-25",
"type": "ct",
"updateable": true,
"privileged": false,
"interface_port": 3003,
"documentation": "https://docs.immich.app/features/ml-hardware-acceleration/",
"website": "https://immich.app/",
"repository": "https://github.com/immich-app/immich",
"architectures": ["amd64"],
"platforms": ["pve"],
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/immich.webp",
"description": "Standalone native Immich machine-learning service for facial recognition and smart search. Uses AMD ROCm when an AMD GPU is passed through to the LXC, with a CPU fallback.",
"install_methods": [
{
"type": "default",
"script": "ct/immich-remote-ml.sh",
"config_path": "/etc/default/immich-remote-ml",
"resources": {
"cpu": 6,
"ram": 12288,
"hdd": 50,
"os": "Debian",
"version": "13"
}
}
],
"default_credentials": {
"username": null,
"password": null
},
"notes": [
"In Immich, set the Machine Learning URL to http://<LXC-IP>:3003. The API has no authentication; restrict TCP port 3003 to the Immich server and trusted LAN.",
"ROCm requires AMD GPU passthrough and a compatible Proxmox host driver. For unsupported gfx1030 devices, set HSA_OVERRIDE_GFX_VERSION=10.3.0 in /etc/default/immich-remote-ml.",
"ROCm libraries and model caches require substantial disk space; the default LXC disk is 50 GiB. CPU backend is selected when no AMD GPU is detected."
]
}