Properly* setting up Immich on an Arm-Based UGREEN NAS which can use the NPU!

A note in advance: This is tested on the ARM variants of the UGREEN Nas. I currently have the UGREEN DH4300 Plus and I assume this works on the two bay variant as well which is the UGREEN NASync DH2300.

*= There are probably loads of other things you can tweak, but this helps with hardware accelleration

A few days ago I received my UGREEN DH4300 Plus, which is an awesome NAS to begin with. I was tempted to get the Intel based ones, but I couldn’t justify the 300 euro’s extra. Of course, having some extra RAM would be nice later down the road but the goal for me is to store images. Luckly, you can easily run Immich on Docker on the 8GB that is has out of the box, which is my goal.

But setting it up, was harder than I expected. Mainly because I wanted to pass the NPU and GPU to the setup so it processes everything a lot faster. In this article, I’ll help you set it up so you can easily run Immich yourself on your UGREEN Nas.

Preparation

First of all, we need Docker. Which is the easiest part in the UGREEN OS. Simply head to the App Center and install Docker:

Done!

Now we need some folders.

Find the Docker folder in the shared folders under files:

Then add an immich folder:

Then make the uploads and db folder in that immich folder:

For those folders, right click them -> then click properties and write down the location of the folders, we’ll need those in the next step.

For now, you can ignore my docker-compose.yml but you do need to make a .env file on your own device. Update the UPLOAD_LOCATION and DB_DATA_LOCATION with the right folders from the step above, they might already be correct but just to be safe:

# You can find documentation for all the supported env variables at https://docs.immich.app/install/environment-variables

# The location where your uploaded files are stored
UPLOAD_LOCATION=/volume1/docker/immich/uploads

# The location where your database files are stored. Network shares are not supported for the database
DB_DATA_LOCATION=/volume1/docker/immich/db

# To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
TZ=Europe/Amsterdam # This needs to be your own timezone

# The Immich version to use. You can pin this to a specific version like "v2.1.0"
IMMICH_VERSION=v2

# Connection secret for postgres. You should change it to a random password
# Please use only the characters `A-Za-z0-9`, without special characters or spaces
DB_PASSWORD=a-super-secure-password-here

# The values below this line do not need to be changed
###################################################################################
DB_USERNAME=postgres
DB_DATABASE_NAME=immich

Please, ensure you set your own DB_PASSWORD and TZ (timezone).

When you’ve done that, upload the .env file in the immich folder on your NAS. It should become invisible directly, which is exactly what we want.

Installation

After some time you’ll see it on your desktop and when you open it you can click the wonderful blue Create button:

For the name fill in immich. For the storage path, select the immich folder in the shared docker location we just made. For the Compose configuration you can do this configuration that I optimised for the UGREEN Nas with processing on the NPU setup out of the box.

name: immich

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    devices:
      - /dev/dri:/dev/dri
      - /dev/mali0:/dev/mali0
      - /dev/mpp_service:/dev/mpp_service
    volumes:
      - ${UPLOAD_LOCATION}:/data
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    ports:
      - '2283:2283'
    depends_on:
      - redis
      - database
    restart: always
    healthcheck:
      disable: false

  immich-machine-learning:
    container_name: immich_machine_learning
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}-rknn
    security_opt:
      - systempaths=unconfined
      - apparmor=unconfined
    devices:
      - /dev/dri:/dev/dri
      - /dev/mali0:/dev/mali0
    volumes:
      - model-cache:/cache
      - /usr/lib/libmali.so.1:/usr/lib/libmali.so
      - /lib/firmware/mali_csffw.bin:/lib/firmware/mali_csffw.bin
    env_file:
      - .env
    environment:
     - MACHINE_LEARNING_RKNN_THREADS=1
    restart: always
    healthcheck:
      disable: false

  redis:
    container_name: immich_redis
    image: docker.io/valkey/valkey:9@sha256:3eeb09785cd61ec8e3be35f8804c8892080f3ca21934d628abc24ee4ed1698f6
    healthcheck:
      test: redis-cli ping || exit 1
    restart: always

  database:
    container_name: immich_postgres
    image: ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0@sha256:bcf63357191b76a916ae5eb93464d65c07511da41e3bf7a8416db519b40b1c23
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      POSTGRES_INITDB_ARGS: '--data-checksums'
    volumes:
      - ${DB_DATA_LOCATION}:/var/lib/postgresql/data
    shm_size: 128mb
    restart: always
    healthcheck:
      disable: false

volumes:
  model-cache:

Now simply deploy

This might take some time. But when it’s done you should see 4 out of the 4 containers running:

Click the immich deployment and click on the immich_server:

Then click the [->] icon on the right and click the port:

You will then be greeted with the setup screen for Immich. I’ve already done this, so you’ll have to fill it in yourself.

After that, we need to do one more thing in the Immich settings is enabling the hardware encoding using RKMPP, which helps speed up video encoding in some cases:

Done!

Now, Immich runs as good as it can get on your UGREEN (at least for the NPU part).

When I, for example, run the Smart Search:

I see the usage of the NPU increase:

Tip: You can make it use more of the NPU by increasing the MACHINE_LEARNING_RKNN_THREADS=1 that I set in the Docker Compose. I really recommend going up to 2, but not 3 since other applications cannot use it and your ML container will use more RAM, which can be a tradeoff on this machine.

After setting MACHINE_LEARNING_RKNN_THREADS to 2 you can see this:






Liking the microblog?

Sign up here so you are always up to date. I don’t spam and it’s completely free knowledge!


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.