Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
74 changes: 74 additions & 0 deletions ct/immichremoteml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/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}" # Immich CUDA runtime wheels and 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 ${APP} installation found!"
exit
fi

if check_for_gh_release "immich-remote-ml" "immich-app/immich"; then
msg_info "Stopping ${APP}"
systemctl stop immich-remote-ml
msg_ok "Stopped ${APP}"

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

msg_info "Updating ${APP}"
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "immich-remote-ml" "immich-app/immich" "tarball" "latest" "$APP_DIR"
UV_SYNC_ARGS=(--project "$ML_SOURCE_DIR" --locked --no-dev --no-install-project --extra "${ML_EXTRA:-cpu}" --python 3.13 --link-mode copy)
if [[ "${ML_EXTRA:-cpu}" == "cuda" ]]; then
UV_SYNC_ARGS+=(--group cuda-libs)
fi
UV_PROJECT_ENVIRONMENT="$VENV_DIR" $STD uv sync "${UV_SYNC_ARGS[@]}"
msg_ok "Updated ${APP}"

msg_info "Starting ${APP}"
safe_service_restart "immich-remote-ml"
msg_ok "Started ${APP}"
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}"
115 changes: 115 additions & 0 deletions install/immichremoteml-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#!/usr/bin/env bash
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os

APP="Immich Remote ML"
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"

$STD apt install -y g++ git

PYTHON_VERSION="3.13" setup_uv
# Let the shared helper install userspace libraries matching the Proxmox host driver.
INSTALL_NVIDIA_DRIVERS=yes setup_hwaccel

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

case "${HWACCEL_VENDOR:-none}" in
amd)
ML_EXTRA="rocm"
DEVICE="rocm"
$STD apt install -y migraphx miopen-hip
msg_ok "AMD ROCm machine-learning backend selected"
;;
nvidia)
ML_EXTRA="cuda"
DEVICE="cuda"
msg_ok "NVIDIA CUDA machine-learning backend selected"
;;
*)
ML_EXTRA="cpu"
DEVICE="cpu"
msg_warn "No supported GPU passthrough detected; using the CPU machine-learning backend"
;;
esac

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

cat <<EOF >/etc/default/immich-remote-ml
ML_EXTRA=$ML_EXTRA
DEVICE=$DEVICE
# For unsupported gfx1030 GPUs, uncomment the following overrides if ROCm reports an architecture error.
# HSA_OVERRIDE_GFX_VERSION=10.3.0
# HSA_USE_SVM=0
EOF

UV_SYNC_ARGS=(--project "$ML_SOURCE_DIR" --locked --no-dev --no-install-project --extra "$ML_EXTRA" --python 3.13 --link-mode copy)
if [[ "$ML_EXTRA" == "cuda" ]]; then
# Immich's CUDA runtime libraries are separate from the ONNX Runtime CUDA extra.
UV_SYNC_ARGS+=(--group cuda-libs)
fi
UV_PROJECT_ENVIRONMENT="$VENV_DIR" $STD uv sync "${UV_SYNC_ARGS[@]}"

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
Environment=CUDA_CACHE_PATH=$CACHE_DIR/jit/cuda
ExecStart=$VENV_DIR/bin/python -m immich_ml
Restart=on-failure
RestartSec=5
TimeoutStartSec=300
TimeoutStopSec=30
PrivateTmp=true
PrivateDevices=false
ProtectSystem=strict
ProtectHome=read-only
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 --now immich-remote-ml.service

if systemctl is-active --quiet immich-remote-ml.service; then
msg_ok "Immich Remote ML is listening on TCP port 3003"
else
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
41 changes: 41 additions & 0 deletions json/immich-remote-ml.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"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. Supports NVIDIA CUDA and AMD ROCm GPU passthrough, with a CPU fallback.",
"install_methods": [
{
"type": "default",
"script": "ct/immichremoteml.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.",
"NVIDIA CUDA requires /dev/nvidia* device passthrough and a compatible host driver (Immich requires NVIDIA compute capability 5.2+ and driver 545+). The installer uses the shared helper to install matching NVIDIA userspace libraries; do not install a kernel driver inside the LXC.",
"AMD 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.",
"CUDA and ROCm libraries plus model caches require substantial disk space; the default LXC disk is 50 GiB. CPU backend is selected when no supported GPU is detected."
]
}