Migrate scientific runtime dependencies and matching Torch builds (#89)

Migrate NumPy and OpenCV together, align torch/torchvision requirements with the CUDA 12.6 wheel index, and update desktop/test dependencies.

Includes the dependency updates proposed in #83, #84, #85, #86 and #87. Validated with six cross-platform CI jobs, actual LaMA image/video comparisons, and Florence-2/LaMA CLI inference on CPU and RTX 4090 CUDA.
This commit is contained in:
D-Ogi authored and GitHub committed 2026-09-16 07:22:20 +02:00
1 parent ae98ac0e10
commit 8af9726666
7 files changed
+84 -17

No files matched your search

+64
View File
@@ -0,0 +1,64 @@
# Scientific runtime migration
This migration applies the updates proposed in #83, #84, #85, #86 and #87 to the
standalone LaMA application introduced in #88. Update the application as a unit:
OpenCV 5 requires NumPy 2 on the supported Python 3.12 environment. Raising only
the OpenCV requirement leaves an unsatisfiable dependency set.
| Component | Application requirement | Lightweight test version |
| --- | --- | --- |
| NumPy | `>=2,<3` | `2.5.3` |
| OpenCV headless | `>=5.0.0.93,<5.1.0` | `5.0.0.93` |
| PyTorch | `>=2.14.0` | Not installed |
| torchvision | `>=0.29.0` | Not installed |
| pywebview | `>=6.2.1`, with Qt extra on Linux | Not installed |
| Matplotlib | Not an application requirement | `3.11.2` |
## Install and device selection
Use a fresh Python 3.12 environment and the instructions in
[LaMA installation](lama-runtime.md#installation-and-migration). Run `pip check`
in the application environment after installation; the separate test environment
cannot establish application dependency compatibility.
Linux setup selects the official CPU index without NVIDIA, or CUDA 12.6 with
NVIDIA. The older CUDA 12.4 index does not contain torch 2.14. The CUDA 12.6 index
provides the matching torch 2.14 / torchvision 0.29 pair. These commands ignore
inherited pip environment options and user configuration. The package mirror
still applies to other application dependencies.
For a manual CUDA 12.6 installation on supported Windows/Linux hardware, install
the matching pair before the application requirements:
```sh
python -m pip --isolated install torch==2.14.0 torchvision==0.29.0 --index-url https://download.pytorch.org/whl/cu126
python -m pip install -r requirements.txt
python -m pip check
python -c "import torch; print(torch.__version__, torch.version.cuda); assert torch.cuda.is_available(); print(torch.ones(1, device='cuda').cpu())"
```
Use the `cpu` index instead of `cu126` for an explicit CPU installation and omit
the CUDA assertion. macOS uses its native PyPI wheels. Windows setup continues to
install from PyPI/the selected package mirror; this migration does not add
hardware detection to the Windows installers. A generic PyPI installation is
not a guarantee of a CUDA build.
An installed CUDA toolkit is not a substitute for a compatible NVIDIA driver and
GPU architecture. Consult [NVIDIA compatibility guidance](https://docs.nvidia.com/deploy/cuda-compatibility/minor-version-compatibility.html)
and [official PyTorch builds](https://download.pytorch.org/whl/cu126/torch/).
CUDA 12.x minor compatibility has feature/PTX limitations on older drivers.
Hardware requiring another build needs an explicitly selected compatible pair.
MPS inference remains outside the validated LaMA device contract.
## Validation scope
CI installs both manifests on Windows/Linux/macOS and checks dependency
resolution, generated TorchScript inference, image/video routing, and a real
JavaScript/Python desktop bridge. The lightweight environment now uses the same
OpenCV major version as the application. Shell cases check CPU/CUDA index
selection, mirror independence and failure propagation.
Real model validation must additionally compare CPU output with the previous
NumPy/OpenCV environment, run both video paths, and exercise Florence-2 and a
named CUDA device. Report concrete results in the pull request; do not infer
GPU or real-model compatibility from the generated fixture alone.
+4 -1
View File
@@ -5,6 +5,9 @@ IOPaint, its model registry/CLI, diffusion backends, and request schemas are no
longer needed. Florence-2 detection, desktop themes and translations retain their
existing behavior.
The current dependency versions and device-selection changes are documented in
[the scientific runtime migration](dependency-migration.md).
## Installation and migration
Use a fresh application environment when upgrading an installation that contains
@@ -92,7 +95,7 @@ If GitHub is unavailable, preseed the cache before running setup:
Linux installs CPU and CUDA PyTorch builds from their respective official wheel
indexes, including when a different mirror is selected for other packages. The
CUDA branch currently selects CUDA 12.4; this is not a promise of support for every
CUDA branch currently selects CUDA 12.6; this is not a promise of support for every
GPU/driver generation. Hardware requiring another build still needs an explicitly
selected compatible torch/torchvision pair.
+4 -4
View File
@@ -1,10 +1,10 @@
# CLI and model runtime. Install a matching torch/torchvision build for your device first.
torch>=2.4.0
torchvision>=0.19.0
torch>=2.14.0
torchvision>=0.29.0
# Native Florence-2 API; pre-4.56 releases do not provide the required model class.
transformers>=4.56.0,<5
numpy>=1.26,<2
opencv-python-headless>=4.8.0,<4.12.0
numpy>=2,<3
opencv-python-headless>=5.0.0.93,<5.1.0
Pillow>=10.0.0
filelock>=3.16
loguru
+3 -3
View File
@@ -1,8 +1,8 @@
# Lightweight CPU suite; does not install the application or model backends.
pytest==9.1.1
ruff==0.16.7
numpy==2.4.6
numpy==2.5.3
Pillow==12.3.0
matplotlib==3.10.8
opencv-python-headless==4.11.0.86
matplotlib==3.11.2
opencv-python-headless==5.0.0.93
filelock==3.32.3
+2 -2
View File
@@ -1,7 +1,7 @@
-r requirements-core.txt
# Desktop UI. Linux needs a concrete backend; Qt wheels avoid a GTK source build.
pywebview>=4.0; sys_platform != "linux"
pywebview[qt]>=4.0; sys_platform == "linux"
pywebview>=6.2.1; sys_platform != "linux"
pywebview[qt]>=6.2.1; sys_platform == "linux"
psutil
pyyaml
+5 -5
View File
@@ -84,20 +84,20 @@ echo " [*] Installing PyTorch..."
if [ "$OS_TYPE" == "macos" ]; then
# macOS: Install from main PyPI (supports MPS on Apple Silicon)
if [ "$CHINA_MODE" == "1" ]; then
pip install "torch>=2.4.0" "torchvision>=0.19.0" --no-cache-dir $PIP_MIRROR -q
pip install "torch>=2.14.0" "torchvision>=0.29.0" --no-cache-dir $PIP_MIRROR -q
else
pip install "torch>=2.4.0" "torchvision>=0.19.0" --no-cache-dir -q
pip install "torch>=2.14.0" "torchvision>=0.29.0" --no-cache-dir -q
fi
echo " [OK] PyTorch installed (MPS support on Apple Silicon)"
else
# Select one wheel index; mixing PyPI/mirrors can silently choose a CPU build.
if command -v nvidia-smi &> /dev/null; then
echo " [*] NVIDIA GPU detected, installing CUDA version..."
python -m pip --isolated install "torch>=2.4.0" "torchvision>=0.19.0" --index-url https://download.pytorch.org/whl/cu124 --no-cache-dir -q
echo " [OK] PyTorch installed (CUDA 12.4)"
python -m pip --isolated install "torch>=2.14.0" "torchvision>=0.29.0" --index-url https://download.pytorch.org/whl/cu126 --no-cache-dir -q
echo " [OK] PyTorch installed (CUDA 12.6)"
else
echo " [*] No NVIDIA GPU detected, installing CPU version..."
python -m pip --isolated install "torch>=2.4.0" "torchvision>=0.19.0" --index-url https://download.pytorch.org/whl/cpu --no-cache-dir -q
python -m pip --isolated install "torch>=2.14.0" "torchvision>=0.29.0" --index-url https://download.pytorch.org/whl/cpu --no-cache-dir -q
echo " [OK] PyTorch installed (CPU)"
fi
fi
+2 -2
View File
@@ -77,8 +77,8 @@ def test_torch_backend_index_is_unambiguous(tmp_path, gpu, mirror):
"""Verify CPU/CUDA index selection independently of the general package mirror."""
result, commands = run_setup(tmp_path, gpu=gpu, mirror=mirror)
assert result.returncode == 0, result.stdout + result.stderr
torch_install = next(args for args in commands if "torch>=2.4.0" in args)
expected = "https://download.pytorch.org/whl/" + ("cu124" if gpu else "cpu")
torch_install = next(args for args in commands if "torch>=2.14.0" in args)
expected = "https://download.pytorch.org/whl/" + ("cu126" if gpu else "cpu")
assert torch_install[torch_install.index("--index-url") + 1] == expected
assert "--isolated" in torch_install
assert "--extra-index-url" not in torch_install