Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ml): configurable batch size for facial recognition #13689

Merged
merged 4 commits into from
Oct 23, 2024

Conversation

mertalev
Copy link
Contributor

@mertalev mertalev commented Oct 22, 2024

Description

The facial recognition model currently receives all faces in an image in one pass. For OpenVINO users, this can lead to surprisingly high RAM usage because of its allocation patterns. This PR sets facial recognition to process faces one by one for OpenVINO without changing the behavior elsewhere. There is a new env to configure the batch size, both for users on e.g. CUDA who also want to set a limit, and for OpenVINO users with beefy systems that want to benefit from batching.

Fixes #13674

How Has This Been Tested?

Tested both with MACHINE_LEARNING_MAX_BATCH_SIZE__FACIAL_RECOGNITION=2 and without setting the env and confirming that face detection works in both cases.

@github-actions github-actions bot added documentation Improvements or additions to documentation 🧠machine-learning labels Oct 22, 2024
| `MACHINE_LEARNING_ANN_FP16_TURBO` | Execute operations in FP16 precision: increasing speed, reducing precision (applies only to ARM-NN) | `False` | machine learning |
| `MACHINE_LEARNING_ANN_TUNING_LEVEL` | ARM-NN GPU tuning level (1: rapid, 2: normal, 3: exhaustive) | `2` | machine learning |
| `MACHINE_LEARNING_DEVICE_IDS`<sup>\*4</sup> | Device IDs to use in multi-GPU environments | `0` | machine learning |
| `MACHINE_LEARNING_MAX_BATCH_SIZE__FACIAL_RECOGNITION` | Set the maximum number of faces that will be processed at once by the facial recognition model | None (`1` if using OpenVINO) | machine learning |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a double underscore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It indicates a nesting level. Since there'll likely be other things batched in the future, these settings are grouped under max_batch_size.

@alextran1502 alextran1502 merged commit 1ec9a60 into main Oct 23, 2024
37 checks passed
@alextran1502 alextran1502 deleted the fix/ml-no-batching-for-openvino branch October 23, 2024 12:50
yosit pushed a commit to yosit/immich that referenced this pull request Oct 24, 2024
…13689)

* configurable batch size, default openvino to 1

* update docs

* don't add a new dependency for two lines

* fix typing
@alakenda
Copy link

Does this commit can solve my problem?
#13700
Can I change 'release' to 'main' to test this commit?

@alakenda
Copy link

Does this commit can solve my problem? #13700 Can I change 'release' to 'main' to test this commit?

I tested,It still not working....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:enhancement documentation Improvements or additions to documentation 🧠machine-learning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

immich_machine_learning openvino [GPU] out of GPU resources N5095 8Gb
4 participants