From bc688a621114820afcbcf4be1d86c692a2f67c8d Mon Sep 17 00:00:00 2001 From: Harvad Li <33759589+bluehawana@users.noreply.github.com> Date: Tue, 14 Jul 2026 14:11:35 +0200 Subject: [PATCH] =?UTF-8?q?coli:=20raise=20RLIMIT=5FNOFILE=20at=20startup?= =?UTF-8?q?=20=E2=80=94=20fixes=20'Too=20many=20open=20files'=20(#147)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The engine opens/mmaps every safetensors shard of the model (144+ files for GLM-5.2). On macOS the default soft fd limit is 256, so a stock terminal session fails while loading with: /out-00125.safetensors: Too many open files the engine exited while loading Raise the soft limit toward the hard limit (capped at 65536) in the coli launcher before spawning the engine, so users don't need a manual 'ulimit -n' in every shell. No-op on Windows and on shells whose limit is already sufficient. Co-authored-by: Harvad Lee Co-authored-by: Claude Fable 5 --- c/coli | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/c/coli b/c/coli index c12852f..54d4239 100755 --- a/c/coli +++ b/c/coli @@ -22,6 +22,17 @@ Configuration through environment variables or flags (also valid after the subco """ import os, sys, subprocess, argparse, json, time, signal, shutil, threading, re, codecs, tempfile, textwrap +# The engine mmaps every shard (144+ files); macOS default RLIMIT_NOFILE is 256. +if sys.platform != "win32": + try: + import resource + _soft, _hard = resource.getrlimit(resource.RLIMIT_NOFILE) + _want = min(65536 if _hard == resource.RLIM_INFINITY else _hard, 65536) + if _soft < _want: + resource.setrlimit(resource.RLIMIT_NOFILE, (_want, _hard)) + except (ImportError, ValueError, OSError): + pass + # Windows: forza output UTF-8 (console cp1252 tronca Unicode box-drawing/emoji) if sys.platform == "win32": for s in (sys.stdout, sys.stderr):