From 594a3aef93af1a08a4e418ef1a45512ee58cce18 Mon Sep 17 00:00:00 2001 From: Ryan Dick Date: Thu, 5 Oct 2023 14:26:45 -0400 Subject: [PATCH] Set MALLOC_MMAP_THRESHOLD_=1048576 by default in invoke.sh. And add it to the manual installation docs. --- docs/installation/020_INSTALL_MANUAL.md | 4 ++++ installer/templates/invoke.sh.in | 3 +++ 2 files changed, 7 insertions(+) diff --git a/docs/installation/020_INSTALL_MANUAL.md b/docs/installation/020_INSTALL_MANUAL.md index 54f8b54565..a19992d266 100644 --- a/docs/installation/020_INSTALL_MANUAL.md +++ b/docs/installation/020_INSTALL_MANUAL.md @@ -256,6 +256,10 @@ manager, please follow these steps: *highly recommended** if your virtual environment is located outside of your runtime directory. + !!! tip + + On linux, it is recommended to run invokeai with the following env var: `MALLOC_MMAP_THRESHOLD_=1048576`. For example: `MALLOC_MMAP_THRESHOLD_=1048576 invokeai --web`. This helps to prevent memory fragmentation that can lead to memory accumulation over time. This env var is set automatically when running via `invoke.sh`. + 10. Render away! Browse the [features](../features/index.md) section to learn about all the diff --git a/installer/templates/invoke.sh.in b/installer/templates/invoke.sh.in index f7fb8e4366..6cf6967608 100644 --- a/installer/templates/invoke.sh.in +++ b/installer/templates/invoke.sh.in @@ -46,6 +46,9 @@ if [ "$(uname -s)" == "Darwin" ]; then export PYTORCH_ENABLE_MPS_FALLBACK=1 fi +# Avoid glibc memory fragmentation. See invokeai/backend/model_management/README.md for details. +export MALLOC_MMAP_THRESHOLD_=1048576 + # Primary function for the case statement to determine user input do_choice() { case $1 in