multimodalart HF Staff commited on
Commit
80e1690
·
verified ·
1 Parent(s): c0937a9

Pin torch 2.11, drop libcudart preload, CUDA diagnostics

Browse files
Files changed (2) hide show
  1. app.py +20 -7
  2. requirements.txt +2 -1
app.py CHANGED
@@ -16,7 +16,6 @@ encoder/decoder overrides.
16
 
17
  from __future__ import annotations
18
 
19
- import ctypes
20
  import glob
21
  import os
22
  import sys
@@ -40,6 +39,23 @@ import torch # noqa: E402
40
  torch.set_float32_matmul_precision("high")
41
 
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  # ---------------------------------------------------------------------------
44
  # 1. gsplat CUDA backend (JIT-compiled once at startup against the ZeroGPU
45
  # image's CUDA toolkit -- gsplat has no prebuilt sm_120 wheel).
@@ -67,12 +83,6 @@ if CUDA_HOME:
67
  os.environ["PATH"] = os.path.join(CUDA_HOME, "bin") + os.pathsep + os.environ.get("PATH", "")
68
  _libdir = os.path.join(CUDA_HOME, "lib64")
69
  os.environ["LD_LIBRARY_PATH"] = _libdir + os.pathsep + os.environ.get("LD_LIBRARY_PATH", "")
70
- for _so in sorted(glob.glob(os.path.join(_libdir, "libcudart.so*")), reverse=True):
71
- try:
72
- ctypes.CDLL(_so, mode=ctypes.RTLD_GLOBAL)
73
- break
74
- except OSError:
75
- continue
76
 
77
  import torch.utils.cpp_extension as _cppext # noqa: E402
78
 
@@ -85,6 +95,7 @@ from gsplat.cuda._backend import _C as _GSPLAT_C # noqa: E402
85
  if _GSPLAT_C is None:
86
  raise RuntimeError(f"gsplat CUDA backend unavailable (CUDA_HOME={CUDA_HOME}).")
87
  print(f"[setup] gsplat backend ready in {time.time() - _t0:.1f}s", flush=True)
 
88
 
89
  # ---------------------------------------------------------------------------
90
  # 2. Compatibility shims for the vendored reference code
@@ -190,6 +201,7 @@ ENCODER, DECODER, DATA_SHIM = build_model(CHECKPOINT_PATH)
190
  ENCODER.to("cuda")
191
  DECODER.to("cuda")
192
  print("[setup] model ready", flush=True)
 
193
 
194
  from src.dataset.shims.crop_shim import rescale_and_crop # noqa: E402
195
  from src.evaluation.metrics import compute_psnr, compute_ssim # noqa: E402
@@ -421,6 +433,7 @@ def reconstruct(
421
  raise gr.Error(str(exc)) from exc
422
  t_sfm = time.time() - t_sfm
423
 
 
424
  progress(0.6, desc="CodecSplat: encode -> bitstream -> decode -> render")
425
  viewer_ply, video, gallery, bin_path, ply_path, s = codecsplat_run(sfm["scene_dir"], float(lmb))
426
 
 
16
 
17
  from __future__ import annotations
18
 
 
19
  import glob
20
  import os
21
  import sys
 
39
  torch.set_float32_matmul_precision("high")
40
 
41
 
42
+ def _nvidia_fds(stage: str) -> None:
43
+ """Diagnostics: /dev/nvidia* handles in the GPU-less main process mean the CUDA
44
+ driver was touched there, which breaks ZeroGPU's forked workers."""
45
+ fds = set()
46
+ for fd in os.listdir("/proc/self/fd"):
47
+ try:
48
+ t = os.readlink(f"/proc/self/fd/{fd}")
49
+ except OSError:
50
+ continue
51
+ if "nvidia" in t:
52
+ fds.add(t)
53
+ print(f"[diag] {stage}: nvidia fds={sorted(fds)}", flush=True)
54
+
55
+
56
+ _nvidia_fds("after torch import")
57
+
58
+
59
  # ---------------------------------------------------------------------------
60
  # 1. gsplat CUDA backend (JIT-compiled once at startup against the ZeroGPU
61
  # image's CUDA toolkit -- gsplat has no prebuilt sm_120 wheel).
 
83
  os.environ["PATH"] = os.path.join(CUDA_HOME, "bin") + os.pathsep + os.environ.get("PATH", "")
84
  _libdir = os.path.join(CUDA_HOME, "lib64")
85
  os.environ["LD_LIBRARY_PATH"] = _libdir + os.pathsep + os.environ.get("LD_LIBRARY_PATH", "")
 
 
 
 
 
 
86
 
87
  import torch.utils.cpp_extension as _cppext # noqa: E402
88
 
 
95
  if _GSPLAT_C is None:
96
  raise RuntimeError(f"gsplat CUDA backend unavailable (CUDA_HOME={CUDA_HOME}).")
97
  print(f"[setup] gsplat backend ready in {time.time() - _t0:.1f}s", flush=True)
98
+ _nvidia_fds("after gsplat")
99
 
100
  # ---------------------------------------------------------------------------
101
  # 2. Compatibility shims for the vendored reference code
 
201
  ENCODER.to("cuda")
202
  DECODER.to("cuda")
203
  print("[setup] model ready", flush=True)
204
+ _nvidia_fds("after model build")
205
 
206
  from src.dataset.shims.crop_shim import rescale_and_crop # noqa: E402
207
  from src.evaluation.metrics import compute_psnr, compute_ssim # noqa: E402
 
433
  raise gr.Error(str(exc)) from exc
434
  t_sfm = time.time() - t_sfm
435
 
436
+ _nvidia_fds("after COLMAP")
437
  progress(0.6, desc="CodecSplat: encode -> bitstream -> decode -> render")
438
  viewer_ply, video, gallery, bin_path, ply_path, s = codecsplat_run(sfm["scene_dir"], float(lmb))
439
 
requirements.txt CHANGED
@@ -1,4 +1,5 @@
1
- torchvision
 
2
  gsplat==1.5.3
3
  ninja
4
  rich
 
1
+ torch==2.11.0
2
+ torchvision==0.26.0
3
  gsplat==1.5.3
4
  ninja
5
  rich