Spaces:
Paused
Paused
safety: cap threads at CPU_THREADS_MAX (default 2) to prevent oversubscription if detection over-reports
Browse files
app.py
CHANGED
|
@@ -57,8 +57,12 @@ def _effective_cpus():
|
|
| 57 |
|
| 58 |
|
| 59 |
_CPU = _effective_cpus()
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
CONTEXT_SIZE = int(os.getenv("CONTEXT_SIZE", "8192")) # incl. image tokens; per-slot = ctx/parallel
|
| 63 |
PARALLEL = int(os.getenv("PARALLEL", "2"))
|
| 64 |
BATCH_SIZE = int(os.getenv("BATCH_SIZE", "512"))
|
|
|
|
| 57 |
|
| 58 |
|
| 59 |
_CPU = _effective_cpus()
|
| 60 |
+
# Hard ceiling on threads: even if detection over-reports (e.g. host cores leak
|
| 61 |
+
# through), never oversubscribe the ~2-vCPU tier. Raise CPU_THREADS_MAX if you
|
| 62 |
+
# move to a bigger CPU tier.
|
| 63 |
+
CPU_THREADS_MAX = int(os.getenv("CPU_THREADS_MAX", "2"))
|
| 64 |
+
CPU_THREADS = min(int(os.getenv("CPU_THREADS", str(_CPU))), CPU_THREADS_MAX)
|
| 65 |
+
CPU_THREADS_BATCH = min(int(os.getenv("CPU_THREADS_BATCH", str(_CPU))), CPU_THREADS_MAX)
|
| 66 |
CONTEXT_SIZE = int(os.getenv("CONTEXT_SIZE", "8192")) # incl. image tokens; per-slot = ctx/parallel
|
| 67 |
PARALLEL = int(os.getenv("PARALLEL", "2"))
|
| 68 |
BATCH_SIZE = int(os.getenv("BATCH_SIZE", "512"))
|