From 21938a4e170cef9073057794bdbc5e809615141a Mon Sep 17 00:00:00 2001 From: MODELBEAST Date: Mon, 13 Jul 2026 01:16:40 +1000 Subject: [PATCH] =?UTF-8?q?sf3d:=20fix=20macOS=20OpenMP=20segfault=20?= =?UTF-8?q?=E2=80=94=20single-threaded=20OMP=20+=20KMP=5FDUPLICATE=5FLIB?= =?UTF-8?q?=5FOK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit torch and the compiled texture_baker/uv_unwrapper each link a libomp. Allowing the duplicate runtime clears 'OMP: Error #15' but the duplicate then corrupts the multithreaded CPU LAPACK path (torch.linalg.svd MPS fallback) -> segfault with no Python traceback. Forcing OMP_NUM_THREADS=1 + MKL_NUM_THREADS=1 removes the threading collision. Verified: clean 1.3MB GLB (13298 verts) in ~5s on M3 Ultra, 9GB peak. SF3D local image->3D now works (weights unlocked by owner HF license). Co-Authored-By: Claude Opus 4.8 --- server/operators/sf3d/run.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/operators/sf3d/run.py b/server/operators/sf3d/run.py index 9ec767e..f95bd6f 100644 --- a/server/operators/sf3d/run.py +++ b/server/operators/sf3d/run.py @@ -36,6 +36,14 @@ cmd = [ ] env = os.environ.copy() env["PYTORCH_ENABLE_MPS_FALLBACK"] = "1" +# torch and the compiled texture_baker/uv_unwrapper each link a libomp. Allowing +# the duplicate runtime avoids "OMP: Error #15", but the duplicate then corrupts +# the multithreaded CPU LAPACK call (torch.linalg.svd MPS fallback) and segfaults +# — forcing single-threaded OpenMP removes the threading collision. Verified: a +# clean GLB on M3 Ultra with all three set. +env["KMP_DUPLICATE_LIB_OK"] = "TRUE" +env["OMP_NUM_THREADS"] = "1" +env["MKL_NUM_THREADS"] = "1" print("+", " ".join(cmd), flush=True) res = subprocess.run(cmd, cwd=str(VENDOR), env=env, stdout=sys.stdout, stderr=subprocess.STDOUT) if res.returncode != 0: