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: