multimodalart HF Staff commited on
Commit
94bf7d3
·
verified ·
1 Parent(s): 4400661

Force OpenBLAS Haswell kernels for COLMAP

Browse files
Files changed (1) hide show
  1. colmap_sfm.py +9 -0
colmap_sfm.py CHANGED
@@ -75,6 +75,12 @@ def run_sfm(
75
  "Upload several overlapping photos of the same scene."
76
  )
77
  log(f"[colmap] {len(names)} images prepared at <= {max_image_size}px")
 
 
 
 
 
 
78
 
79
  database_path = workdir / "colmap.db"
80
  if database_path.exists():
@@ -201,6 +207,9 @@ def run_sfm_subprocess(image_paths, workdir, max_image_size=1280, matcher="exhau
201
  env = {k: v for k, v in os.environ.items() if k not in ("LD_PRELOAD",)}
202
  env["LD_LIBRARY_PATH"] = os.environ.get("_ORIG_LD_LIBRARY_PATH", "")
203
  env["OPENBLAS_NUM_THREADS"] = "1"
 
 
 
204
  env.pop("CUDA_VISIBLE_DEVICES", None)
205
  proc = subprocess.run([sys.executable, os.path.abspath(__file__), str(spec)], env=env,
206
  capture_output=True, text=True, timeout=timeout)
 
75
  "Upload several overlapping photos of the same scene."
76
  )
77
  log(f"[colmap] {len(names)} images prepared at <= {max_image_size}px")
78
+ try:
79
+ import os as _os
80
+ cpu = next((l.split(":", 1)[1].strip() for l in open("/proc/cpuinfo") if l.startswith("model name")), "?")
81
+ log(f"[colmap] cpu={cpu} ncpu={_os.cpu_count()} OPENBLAS_CORETYPE={_os.environ.get('OPENBLAS_CORETYPE')}")
82
+ except Exception:
83
+ pass
84
 
85
  database_path = workdir / "colmap.db"
86
  if database_path.exists():
 
207
  env = {k: v for k, v in os.environ.items() if k not in ("LD_PRELOAD",)}
208
  env["LD_LIBRARY_PATH"] = os.environ.get("_ORIG_LD_LIBRARY_PATH", "")
209
  env["OPENBLAS_NUM_THREADS"] = "1"
210
+ # Force a well-tested OpenBLAS kernel set: auto-detected kernels on some Space CPUs
211
+ # give garbage results (every image fails to register after the initial pair).
212
+ env["OPENBLAS_CORETYPE"] = "Haswell"
213
  env.pop("CUDA_VISIBLE_DEVICES", None)
214
  proc = subprocess.run([sys.executable, os.path.abspath(__file__), str(spec)], env=env,
215
  capture_output=True, text=True, timeout=timeout)