art/setup.py: macOS unterstützen (GPU-Erkennung, PEP 668, TLS-Hinweis)
- GPU-Variante wird erkannt statt pauschal --nvidia: darwin -> --m-series, nvidia-smi -> --nvidia, rocminfo -> --amd, sonst --cpu; überschreibbar. - deps fängt 'externally-managed-environment' ab und verweist auf uv/venv. - Download meldet CERTIFICATE_VERIFY_FAILED mit dem macOS-Fix. - check zeigt Plattform + ComfyUI-Variante, Broken-Pipe endet nicht im Traceback. - SETUP.md: §4.1 macOS (pixelize identisch, FLUX.2 fp8 nur bedingt, SDXL als Mac-Weg, Speicherbänder 16/32/64 GB).
This commit is contained in:
parent
b8e8fbbbe6
commit
203fef81f7
2 changed files with 142 additions and 26 deletions
55
art/SETUP.md
55
art/SETUP.md
|
|
@ -11,10 +11,12 @@ git clone https://repos.zauberturm.de/torsten/taloria.git
|
|||
cd taloria
|
||||
|
||||
python3 art/tools/setup.py check # Ist-Zustand, ändert nichts
|
||||
python3 art/tools/setup.py all ~/Dokumente/workbench_taloria --nvidia
|
||||
python3 art/tools/setup.py all ~/Dokumente/workbench_taloria
|
||||
python3 art/tools/setup.py check --smoke # muss mit Exit 0 enden
|
||||
```
|
||||
|
||||
Die GPU-Variante wird erkannt (Linux+NVIDIA → `--nvidia`, macOS → `--m-series`,
|
||||
sonst `--cpu`); überschreiben mit `--nvidia`, `--amd`, `--mps`, `--cpu`.
|
||||
`all` macht `deps` → `comfy` → `models` → `workbench` in dieser Reihenfolge und
|
||||
ist idempotent. Einzelschritte, wenn etwas schiefgeht:
|
||||
|
||||
|
|
@ -38,6 +40,8 @@ fal.ai (§5 in `WORKFLOW.md`) — nicht lokal.
|
|||
- `comfy-cli` (Referenz: 1.25.0) — `uv tool install comfy-cli` oder
|
||||
`pip install --user comfy-cli`
|
||||
- Für lokale Generierung: NVIDIA mit ~16 GB VRAM (Referenz: RTX 5060 Ti).
|
||||
Mac: siehe [§4.1](#41-macos) — Nachbearbeitung ja, FLUX.2 nur ab 32 GB
|
||||
Unified Memory sinnvoll.
|
||||
Das Gespann 9B-fp8 + 8B-Textencoder läuft bei 1280×704 in ~2 min, weil die
|
||||
beiden nacheinander gehalten werden.
|
||||
|
||||
|
|
@ -100,6 +104,53 @@ Kommt ein Bild in 1280×720 mit 64 Farben heraus, ist die Kette komplett.
|
|||
`setup.py check --smoke` prüft dieselbe Kette ohne GPU in zwei Sekunden
|
||||
(Testbild → `pixelize` → Palette und 4×-Raster).
|
||||
|
||||
## 4.1 macOS
|
||||
|
||||
Die Nachbearbeitung ist hier vollwertig, die Generierung eingeschränkt — und
|
||||
zwar aus zwei physikalischen Gründen, nicht aus Softwaregründen.
|
||||
|
||||
| Teil | Mac | Warum |
|
||||
|---|---|---|
|
||||
| `pixelize.py` | **identisch** | reines Pillow, kein GPU-Code, keine Plattformpfade |
|
||||
| `setup.py` | **identisch** | nur stdlib; erkennt macOS und wählt `--m-series` |
|
||||
| Workbench/Symlinks | **identisch** | APFS kann Symlinks; im Finder mit Aliaspfeil |
|
||||
| SDXL (6,9 GB) | **gut** | bf16/fp16 läuft nativ auf MPS, das ist der Mac-Weg |
|
||||
| FLUX.2 klein 9B (9,5 GB fp8) | **bedingt** | kein natives fp8 auf MPS → Gewichte werden hochgecastet, also mehr Speicher und deutlich langsamer |
|
||||
|
||||
Konkret zur Hardware:
|
||||
|
||||
- **Apple Silicon, 16 GB** — FLUX.2 9B ist nicht sinnvoll (Textencoder 8 GB
|
||||
kommt noch dazu). SDXL lokal oder fal.ai.
|
||||
- **Apple Silicon, 32 GB** — FLUX.2 versuchen, aber mit Erwartung „Minuten pro
|
||||
Bild statt Sekunden und evtl. Swap". Wenn es zäh wird: SDXL.
|
||||
- **Apple Silicon, 64 GB+** — FLUX.2 9B läuft brauchbar; trotzdem langsamer als
|
||||
die RTX 5060 Ti.
|
||||
- **Intel-Mac** — keine sinnvolle lokale Diffusion. `fal.ai` (Endpoints in
|
||||
`WORKFLOW.md` §5) oder Comfy Cloud; die Assets, Prompts und `pixelize` sind
|
||||
trotzdem alle nutzbar.
|
||||
|
||||
Auf einem Mac also:
|
||||
|
||||
```bash
|
||||
python3 art/tools/setup.py all ~/workbench/taloria --mps
|
||||
python3 art/tools/setup.py models --optional # SDXL mitnehmen
|
||||
```
|
||||
|
||||
Zwei macOS-spezifische Stolpersteine, die `setup.py` abfängt:
|
||||
|
||||
- **Homebrew-Python** verweigert `pip install --user` (PEP 668). Das Skript
|
||||
sagt das und verweist auf `uv tool install comfy-cli` bzw. ein venv.
|
||||
- **python.org-Python** ohne Zertifikate scheitert beim Download mit
|
||||
`CERTIFICATE_VERIFY_FAILED`. Abhilfe:
|
||||
`/Applications/Python\ 3.*/Install\ Certificates.command`.
|
||||
- Apples mitgeliefertes `python3` ist teils 3.9 — zu alt. `brew install python`
|
||||
oder `uv python install` nehmen; `check` meldet es vorher.
|
||||
|
||||
**Folge für „identisch":** auf dem Mac bekommst du dieselben Prompts,
|
||||
dieselben Parameter und dieselbe Pipeline — aber andere Bilder, weil MPS ein
|
||||
anderes Device ist (siehe §5). Für Szenen, die byte-gleich zum Referenzlauf
|
||||
sein müssen, ist der Mac der falsche Ort.
|
||||
|
||||
## 5. Was „identisch" heißt — und was nicht
|
||||
|
||||
Gleich sind: Prompts, Seeds, `pixelize`-Parameter, Jobdateien, Paletten,
|
||||
|
|
@ -109,7 +160,7 @@ Nicht gleich, und zwar by design:
|
|||
|
||||
| Quelle der Abweichung | Wirkung |
|
||||
|---|---|
|
||||
| **Device** (GPU vs. CPU) | derselbe Seed liefert ein anderes Bild (mittlere Abweichung ~12/255, fp8-Kernel numerisch verschieden). Auf demselben Device ist der Lauf pixelgenau deterministisch. |
|
||||
| **Device** (NVIDIA vs. CPU/MPS) | derselbe Seed liefert ein anderes Bild (mittlere Abweichung ~12/255, fp8-Kernel numerisch verschieden). Auf demselben Device ist der Lauf pixelgenau deterministisch. |
|
||||
| **ComfyUI-/torch-Version** | Sampler- und Scheduler-Details ändern sich zwischen Releases → gleiche Seeds, andere Bilder. Referenzstand: ComfyUI 0.44.0, torch 2.14.1+cu130, comfy-cli 1.25.0, Python 3.12.3. `setup.py check` zeigt jede Abweichung. |
|
||||
| **GPU-Modell** | andere Karte = andere Kernel = anderes Bild, auch bei gleicher Version. |
|
||||
| **Pillow-Major** | auto-quantisierten Paletten können um einzelne Farben springen. Palette mit `--palette <freigegebenes Asset>` erzwingen, wenn es exakt sein muss. |
|
||||
|
|
|
|||
|
|
@ -22,7 +22,9 @@ from __future__ import annotations
|
|||
import argparse
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import ssl
|
||||
import subprocess
|
||||
import sys
|
||||
import urllib.error
|
||||
|
|
@ -164,6 +166,36 @@ def comfy_bin() -> str | None:
|
|||
return shutil.which("comfy")
|
||||
|
||||
|
||||
GPU_FLAGS = {
|
||||
"nvidia": "--nvidia",
|
||||
"amd": "--amd",
|
||||
"mps": "--m-series",
|
||||
"cpu": "--cpu",
|
||||
}
|
||||
|
||||
|
||||
def detect_gpu() -> str:
|
||||
"""Welche ComfyUI-Variante ist auf dieser Kiste die richtige?"""
|
||||
if sys.platform == "darwin":
|
||||
return "mps"
|
||||
if shutil.which("nvidia-smi"):
|
||||
return "nvidia"
|
||||
if shutil.which("rocminfo"):
|
||||
return "amd"
|
||||
return "cpu"
|
||||
|
||||
|
||||
def resolve_gpu(gpu: str) -> str:
|
||||
return detect_gpu() if gpu == "auto" else gpu
|
||||
|
||||
|
||||
def pip_hint() -> None:
|
||||
say(" Hinweis: viele Distributionen (Homebrew/macOS, Debian) verweigern")
|
||||
say(" 'pip install --user' (PEP 668). Dann eine der beiden Varianten:")
|
||||
say(" brew install uv && uv tool install comfy-cli")
|
||||
say(" python3 -m venv ~/.venvs/art && ~/.venvs/art/bin/pip install -r art/requirements.txt comfy-cli")
|
||||
|
||||
|
||||
def run(cmd: list[str], *, check: bool = True, capture: bool = False) -> subprocess.CompletedProcess:
|
||||
return subprocess.run(
|
||||
cmd,
|
||||
|
|
@ -227,6 +259,16 @@ def cmd_check(args: argparse.Namespace) -> int:
|
|||
say(f" FEHLT Python {sys.version.split()[0]} (>= {'.'.join(map(str, PY_MIN))} nötig)")
|
||||
problems.append("Python zu alt")
|
||||
|
||||
head("Plattform")
|
||||
say(f" {sys.platform} {platform.machine()} (ComfyUI-Variante: {detect_gpu()})")
|
||||
if sys.platform == "darwin":
|
||||
say(" Referenz ist Linux + NVIDIA. pixelize.py und die Assets sind hier")
|
||||
say(" identisch; Generierung über MPS ist langsamer und nicht bit-gleich.")
|
||||
if platform.machine() == "arm64":
|
||||
say(" Für FLUX.2 9B: 32 GB Unified Memory empfohlen, sonst SDXL.")
|
||||
else:
|
||||
say(" Intel-Mac: lokal keine sinnvolle Diffusion — fal.ai oder Comfy Cloud.")
|
||||
|
||||
head("pixelize.py-Abhängigkeiten")
|
||||
pv = pillow_version()
|
||||
if pv:
|
||||
|
|
@ -353,8 +395,14 @@ def cmd_deps(args: argparse.Namespace) -> int:
|
|||
if dry:
|
||||
say(" (dry-run: pip install --user -r art/requirements.txt)")
|
||||
else:
|
||||
run([sys.executable, "-m", "pip", "install", "--user", "-r", str(ART / "requirements.txt")])
|
||||
say(f" ok {pillow_version() or 'installiert'}")
|
||||
try:
|
||||
run([sys.executable, "-m", "pip", "install", "--user",
|
||||
"-r", str(ART / "requirements.txt")])
|
||||
say(f" ok {pillow_version() or 'installiert'}")
|
||||
except subprocess.CalledProcessError:
|
||||
say(" pip hat abgelehnt.")
|
||||
pip_hint()
|
||||
return 1
|
||||
|
||||
head("comfy-cli")
|
||||
if comfy_bin():
|
||||
|
|
@ -364,10 +412,15 @@ def cmd_deps(args: argparse.Namespace) -> int:
|
|||
if dry:
|
||||
say(" (dry-run: uv tool install comfy-cli)")
|
||||
return 0
|
||||
if shutil.which("uv"):
|
||||
run(["uv", "tool", "install", "comfy-cli"])
|
||||
else:
|
||||
run([sys.executable, "-m", "pip", "install", "--user", "comfy-cli"])
|
||||
try:
|
||||
if shutil.which("uv"):
|
||||
run(["uv", "tool", "install", "comfy-cli"])
|
||||
else:
|
||||
run([sys.executable, "-m", "pip", "install", "--user", "comfy-cli"])
|
||||
except subprocess.CalledProcessError:
|
||||
say(" Installation fehlgeschlagen.")
|
||||
pip_hint()
|
||||
return 1
|
||||
if not comfy_bin():
|
||||
say(" comfy-cli liegt nicht im PATH.")
|
||||
say(" Nach der Installation neu einloggen oder ~/.local/bin in den PATH legen.")
|
||||
|
|
@ -392,15 +445,16 @@ def cmd_comfy(args: argparse.Namespace) -> int:
|
|||
say(f"ComfyUI ist schon da: {ws} — nichts zu tun.")
|
||||
return 0
|
||||
|
||||
flag = {
|
||||
"nvidia": "--nvidia",
|
||||
"amd": "--amd",
|
||||
"mps": "--m-series",
|
||||
"cpu": "--cpu",
|
||||
}[args.gpu]
|
||||
gpu = resolve_gpu(args.gpu)
|
||||
flag = GPU_FLAGS[gpu]
|
||||
|
||||
head(f"ComfyUI installieren ({args.gpu})")
|
||||
head(f"ComfyUI installieren ({gpu})")
|
||||
if args.gpu == "auto":
|
||||
say(f" erkannt {sys.platform} -> {gpu}")
|
||||
say(" comfy-cli lädt ComfyUI + PyTorch, das sind einige GB. Das dauert.")
|
||||
if gpu == "mps":
|
||||
say(" macOS: läuft, aber langsam. Für FLUX.2 9B sollten es 32 GB")
|
||||
say(" Unified Memory sein; 16-GB-Macs nehmen besser SDXL (oder fal.ai).")
|
||||
cmd = [exe, "--skip-prompt", "install", flag]
|
||||
if args.version:
|
||||
cmd += ["--version", args.version]
|
||||
|
|
@ -411,10 +465,11 @@ def cmd_comfy(args: argparse.Namespace) -> int:
|
|||
run(cmd)
|
||||
ws = workspace()
|
||||
say(f" ok {ws}")
|
||||
if ws and comfyui_version(ws) != REFERENCE_ENV["ComfyUI"]:
|
||||
say(f" Hinweis Referenz war ComfyUI {REFERENCE_ENV['ComfyUI']} "
|
||||
f"(hier: {comfyui_version(ws) or '?'}). Für pixelgenaue Reproduktion "
|
||||
f"--version {REFERENCE_ENV['ComfyUI']} setzen.")
|
||||
ver = comfyui_version(ws) if ws else None
|
||||
if ver != REFERENCE_ENV["ComfyUI"]:
|
||||
say(f" Hinweis Referenz war ComfyUI {REFERENCE_ENV['ComfyUI']} (hier: {ver or '?'}). "
|
||||
f"Für pixelgenaue Reproduktion --version {REFERENCE_ENV['ComfyUI']} setzen — "
|
||||
f"das gilt nur auf gleicher Hardware.")
|
||||
return 0
|
||||
|
||||
|
||||
|
|
@ -467,7 +522,12 @@ def download(m: Model, ws: Path) -> bool:
|
|||
return False
|
||||
except urllib.error.URLError as e:
|
||||
part.unlink(missing_ok=True)
|
||||
say(f" FEHLER Netzwerk: {e.reason}")
|
||||
if "CERTIFICATE_VERIFY_FAILED" in str(e.reason) or isinstance(e.reason, ssl.SSLCertVerificationError):
|
||||
say(" FEHLER TLS-Zertifikat nicht vertraut.")
|
||||
say(" macOS mit python.org-Installer:")
|
||||
say(" /Applications/Python\\ 3.*/Install\\ Certificates.command")
|
||||
else:
|
||||
say(f" FEHLER Netzwerk: {e.reason}")
|
||||
return False
|
||||
|
||||
got = part.stat().st_size
|
||||
|
|
@ -612,14 +672,14 @@ def main(argv: list[str] | None = None) -> int:
|
|||
c = sub.add_parser("deps", help="Pillow und comfy-cli installieren")
|
||||
c.set_defaults(func=cmd_deps)
|
||||
|
||||
c = sub.add_parser("comfy", help="ComfyUI-Workspace anlegen")
|
||||
c = sub.add_parser("comfy", help="ComfyUI-Workspace anlegen (GPU wird erkannt)")
|
||||
c.add_argument("--nvidia", dest="gpu", action="store_const", const="nvidia")
|
||||
c.add_argument("--amd", dest="gpu", action="store_const", const="amd")
|
||||
c.add_argument("--mps", dest="gpu", action="store_const", const="mps")
|
||||
c.add_argument("--mps", dest="gpu", action="store_const", const="mps", help="Apple Silicon")
|
||||
c.add_argument("--cpu", dest="gpu", action="store_const", const="cpu")
|
||||
c.add_argument("--version", help="ComfyUI-Version (Referenz: %s)" % REFERENCE_ENV["ComfyUI"])
|
||||
c.add_argument("--dry-run", action="store_true")
|
||||
c.set_defaults(func=cmd_comfy, gpu="nvidia", dry_run=False)
|
||||
c.set_defaults(func=cmd_comfy, gpu="auto", dry_run=False)
|
||||
|
||||
c = sub.add_parser("models", help="Modellgewichte laden und per Größe prüfen")
|
||||
c.add_argument("--optional", action="store_true", help="auch SDXL und die Pixel-LoRA")
|
||||
|
|
@ -635,12 +695,12 @@ def main(argv: list[str] | None = None) -> int:
|
|||
c.add_argument("dir", nargs="?", help="Workbench-Zielordner")
|
||||
c.add_argument("--nvidia", dest="gpu", action="store_const", const="nvidia")
|
||||
c.add_argument("--amd", dest="gpu", action="store_const", const="amd")
|
||||
c.add_argument("--mps", dest="gpu", action="store_const", const="mps")
|
||||
c.add_argument("--mps", dest="gpu", action="store_const", const="mps", help="Apple Silicon")
|
||||
c.add_argument("--cpu", dest="gpu", action="store_const", const="cpu")
|
||||
c.add_argument("--version", help="ComfyUI-Version")
|
||||
c.add_argument("--optional", action="store_true", help="auch die optionalen Modelle")
|
||||
c.add_argument("--dry-run", action="store_true")
|
||||
c.set_defaults(func=cmd_all, gpu="nvidia", dry_run=False, force=False)
|
||||
c.set_defaults(func=cmd_all, gpu="auto", dry_run=False, force=False)
|
||||
|
||||
args = p.parse_args(argv)
|
||||
args.dir = getattr(args, "dir", None)
|
||||
|
|
@ -648,4 +708,9 @@ def main(argv: list[str] | None = None) -> int:
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
try:
|
||||
sys.exit(main())
|
||||
except BrokenPipeError:
|
||||
# `setup.py check | head` soll nicht mit Traceback enden.
|
||||
os.dup2(os.open(os.devnull, os.O_WRONLY), sys.stdout.fileno())
|
||||
sys.exit(0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue