Immich Machine Learning GPU & TensorRT Setup

Googled777 avatar   
Googled777
Modern, working doctrine for enabling NVIDIA RTX GPU + TensorRT acceleration for Immich’s machine learning worker using Docker & Docker Compose. <br> <br>Immich v2 NVIDIA RTX Docker Compose CUDA & Ten..


Immich – Full GPU Deployment Guide (Docker + NVIDIA)

Immich – Full GPU Deployment Guide (Docker + NVIDIA)

Docker NVIDIA GPU TensorRT Production 2025

This guide walks you from a clean Ubuntu install to a fully GPU‑accelerated Immich deployment using Docker, NVIDIA Container Toolkit, Redis, and pgvector‑enabled Postgres. This is the exact architecture used on Johannes and validated on Signal Raider.

1. Install Docker

sudo apt update
sudo apt install -y ca-certificates curl gnupg

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
  sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

echo \
  "deb [arch=$(dpkg --print-architecture) \
  signed-by=/etc/apt/keyrings/docker.gpg] \
  https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

2. Install NVIDIA GPU Drivers

sudo apt install -y nvidia-driver-535
sudo reboot

3. Install NVIDIA Container Toolkit

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | \
  sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg

curl -s -L https://nvidia.github.io/libnvidia-container/ubuntu$(lsb_release -rs)/libnvidia-container.list | \
  sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
  sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

sudo apt update
sudo apt install -y nvidia-container-toolkit

sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

4. Verify GPU passthrough

docker run --rm --gpus all nvidia/cuda:12.2.0-base nvidia-smi
You should see your GPU (e.g., RTX 4070, RTX 4080).

5. Create Immich directory

mkdir -p /opt/immich
cd /opt/immich

6. Create .env

IMMICH_VERSION=release
DB_USERNAME=immich
DB_PASSWORD=immich
DB_DATABASE_NAME=immich

7. Create docker-compose.yml

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    depends_on:
      - redis
      - database
    env_file:
      - .env
    volumes:
      - immich_upload:/usr/src/app/upload
    restart: always

  immich-machine-learning:
    container_name: immich_machine_learning
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}-cuda
    env_file:
      - .env
    volumes:
      - model-cache:/cache
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]
    restart: always

  redis:
    container_name: immich_redis
    image: redis:7
    restart: always

  database:
    container_name: immich_postgres
    image: tensorchord/pgvecto-rs:pg14-v0.2.0
    environment:
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_DB: ${DB_DATABASE_NAME}
    volumes:
      - pgdata:/var/lib/postgresql/data
    restart: always

volumes:
  immich_upload:
  pgdata:
  model-cache:

8. Start Immich

docker compose up -d

9. Access Immich

  • Signal Raider / MSI: http://localhost:2283
  • Johannes: via HAProxy backend

10. GPU verification inside Immich

Inside the Immich UI:
  • Settings → Machine Learning
  • You should see CUDA available
  • Indexing photos should spike GPU usage to 80–95%

Production Notes (Johannes)

  • Remove ports: from the server container
  • Let HAProxy handle TLS + routing
  • Use bind mounts for long‑term storage
  • Snapshot pgdata regularly
0 Comentarios

No se encontraron comentarios