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
|
|
@ -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