[object Object]

← back to Exo

Edit configure_mlx.sh for calculate dinamically the value for iogpu.wired_limit_mb and iogpu.wired_lwm_mb. The script limit wired_limit_mb to 80% and wired_lwm_mb to 60%, but this threshold are variables.

b0d7c34efad1037de020164869cbea5da2cbcefa · 2024-11-13 17:30:50 +0100 · Giuseppe Gambino

Files touched

Diff

commit b0d7c34efad1037de020164869cbea5da2cbcefa
Author: Giuseppe Gambino <giuseppe.gambino.g92@gmail.com>
Date:   Wed Nov 13 17:30:50 2024 +0100

    Edit configure_mlx.sh for calculate dinamically the value for iogpu.wired_limit_mb and iogpu.wired_lwm_mb. The script limit wired_limit_mb to 80% and wired_lwm_mb to 60%, but this threshold are variables.
---
 configure_mlx.sh | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/configure_mlx.sh b/configure_mlx.sh
index 38cc61a1..90283968 100755
--- a/configure_mlx.sh
+++ b/configure_mlx.sh
@@ -1,3 +1,23 @@
-# this needs to be dynamic
-# sudo sysctl iogpu.wired_lwm_mb=400000
-# sudo sysctl iogpu.wired_limit_mb=180000
+#!/bin/bash
+
+# Get the total memory in MB
+TOTAL_MEM_MB=$(($(sysctl -n hw.memsize) / 1024 / 1024))
+
+# Calculate the maximum limit as 80% of the total memory
+WIRED_LIMIT_MB=$(($TOTAL_MEM_MB * 80 / 100))
+
+# Calculate the lower bound as 60%-80% of the maximum limit
+WIRED_LWM_MIN=$(($WIRED_LIMIT_MB * 60 / 100))
+WIRED_LWM_MAX=$(($WIRED_LIMIT_MB * 80 / 100))
+
+# Choose a mid-range value for wired_lwm_mb
+WIRED_LWM_MB=$(($WIRED_LWM_MIN + ($WIRED_LWM_MAX - $WIRED_LWM_MIN) / 2))
+
+# Display the calculated values
+echo "Total memory: $TOTAL_MEM_MB MB"
+echo "Maximum limit (iogpu.wired_limit_mb): $WIRED_LIMIT_MB MB"
+echo "Lower bound (iogpu.wired_lwm_mb): $WIRED_LWM_MB MB"
+
+# Apply the values with sysctl
+sudo sysctl -w iogpu.wired_limit_mb=$WIRED_LIMIT_MB
+sudo sysctl -w iogpu.wired_lwm_mb=$WIRED_LWM_MB

← b6945224 disable configure_mlx.sh for now  ·  back to Exo  ·  adding logic to check which models are downloaded c7dd3126 →