fix: pin torch cu126 for GPU compatibility and fix cross-platform bugs

- Pin torch==2.6.0+cu126 and torchvision==0.21.0+cu126 in feature
  manifest to prevent NCCL symbol mismatch on CUDA 12.6 base images
- Move lpips after torch in install order to prevent wrong version
  resolution from PyPI
- Add einops to upscale-enhance common deps (required by SCUNet)
- Update cpu_fallback_packages to handle multi-package CUDA torch
  entries on amd64 without GPU
- Fix gpu.py ONNX CUDA detection: replace hardcoded .so path with
  cross-platform session smoke-test
- Fix os.dup(1) crashes on Windows in upscale, enhance_faces, and
  noise_removal by wrapping in try/except with sys.stderr fallback
- Guard top-level numpy/cv2 imports in colorize.py and restore.py
  with helpful error messages
- Add weights_only=False fallback for torch.load in noise_removal
- Fix integration tests to accept 501 for uninstalled AI features
  and 422 for missing system tools (exiftool, libheif)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ashim
2026-04-20 15:17:08 +08:00
co-authored by Claude Opus 4.6
parent ac5fdfb841
commit 01d30cfb61
10 changed files with 209 additions and 195 deletions
+12 -4
View File
@@ -94,8 +94,14 @@ def main():
# Libraries like basicsr, realesrgan, gfpgan, and torch print
# download progress and init messages to stdout which would
# corrupt our JSON result.
stdout_fd = os.dup(1)
os.dup2(2, 1)
stdout_fd = None
try:
stdout_fd = os.dup(1)
os.dup2(2, 1)
except OSError:
# os.dup may fail on Windows with piped stdio
stdout_fd = None
sys.stdout = sys.stderr
try:
from basicsr.archs.rrdbnet_arch import RRDBNet
@@ -166,8 +172,10 @@ def main():
finally:
# Restore stdout after ALL AI processing
os.dup2(stdout_fd, 1)
os.close(stdout_fd)
if stdout_fd is not None:
os.dup2(stdout_fd, 1)
os.close(stdout_fd)
sys.stdout = sys.__stdout__
except (ImportError, FileNotFoundError, RuntimeError, OSError) as e:
import traceback