[PR #3797] [MERGED] chore(ml): make lazy loading default #10119

Closed
opened 2026-02-05 14:16:19 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/immich-app/immich/pull/3797
Author: @mertalev
Created: 8/20/2023
Status: Merged
Merged: 8/21/2023
Merged by: @alextran1502

Base: mainHead: chore/ml-lazy-loading


📝 Commits (1)

  • 25bbb71 make lazy loading default

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 machine-learning/app/config.py (+1 -1)

📄 Description

Description

This change means a model will only load when the ML service receives a relevant request. This doesn't change unloading behavior, so models will stay loaded by default. Additionally, models will still be downloaded on startup. The benefit of this change is to optimize RAM usage. Notably, disabling particular ML jobs with #3768 means the corresponding model won't be loaded.

How Has This Been Tested?

I ran docker stats --no-stream after startup, confirming low RAM usage for immich_machine_learning at under 300mb. I then started and stopped one ML job at a time and checked docker stats --no-stream again for each, confirming the expected increase in RAM with each model.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/immich-app/immich/pull/3797 **Author:** [@mertalev](https://github.com/mertalev) **Created:** 8/20/2023 **Status:** ✅ Merged **Merged:** 8/21/2023 **Merged by:** [@alextran1502](https://github.com/alextran1502) **Base:** `main` ← **Head:** `chore/ml-lazy-loading` --- ### 📝 Commits (1) - [`25bbb71`](https://github.com/immich-app/immich/commit/25bbb710a76c88e08598bb2e5a699ae6c0fd6f8f) make lazy loading default ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `machine-learning/app/config.py` (+1 -1) </details> ### 📄 Description ## Description This change means a model will only load when the ML service receives a relevant request. This doesn't change unloading behavior, so models will stay loaded by default. Additionally, models will still be downloaded on startup. The benefit of this change is to optimize RAM usage. Notably, disabling particular ML jobs with #3768 means the corresponding model won't be loaded. ## How Has This Been Tested? I ran `docker stats --no-stream` after startup, confirming low RAM usage for `immich_machine_learning` at under 300mb. I then started and stopped one ML job at a time and checked `docker stats --no-stream` again for each, confirming the expected increase in RAM with each model. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 14:16:19 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#10119