Merge pull request #68 from outis1one/claude/focused-maxwell-3kgh3x
Make model prefetching automatic in install/run scripts
This commit is contained in:
@@ -11,7 +11,7 @@ git clone https://github.com/outis1one/editmaskwithai
|
|||||||
cd editmaskwithai
|
cd editmaskwithai
|
||||||
|
|
||||||
# One-time setup: installs nvidia-container-toolkit, configures Docker,
|
# One-time setup: installs nvidia-container-toolkit, configures Docker,
|
||||||
# and sets up a permanent DNS fix so the container can download models.
|
# sets up a permanent DNS fix, and prefetches all AI models on the host.
|
||||||
chmod +x install-local-gpu.sh
|
chmod +x install-local-gpu.sh
|
||||||
./install-local-gpu.sh
|
./install-local-gpu.sh
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ chmod +x bring-up-local-gpu.sh
|
|||||||
|
|
||||||
Open **http://localhost:3080**
|
Open **http://localhost:3080**
|
||||||
|
|
||||||
**First startup downloads the AI model for your GPU (~13 GB, one time).** Models are cached in `./data/hf_cache/` and survive rebuilds.
|
**Models (~13 GB total, one time) download automatically on the host**, outside Docker — both scripts call `./prefetch-models.sh` for you, since in-container DNS is unreliable on some hosts. They're cached in `./data/hf_cache/` and `./data/models/`, and survive rebuilds.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ EditmaskwithAI/
|
|||||||
├── Dockerfile.gpu
|
├── Dockerfile.gpu
|
||||||
├── install-local-gpu.sh # One-time GPU host setup
|
├── install-local-gpu.sh # One-time GPU host setup
|
||||||
├── bring-up-local-gpu.sh # Start/stop the GPU container
|
├── bring-up-local-gpu.sh # Start/stop the GPU container
|
||||||
├── prefetch-models.sh # Download AI models on the host (DNS-blocked workaround)
|
├── prefetch-models.sh # Download AI models on the host (called automatically; also runnable standalone)
|
||||||
└── .env.example
|
└── .env.example
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ You can also pick a specific model per-edit from the Remove Background dialog's
|
|||||||
|
|
||||||
**AI models not downloading (container DNS blocked)**
|
**AI models not downloading (container DNS blocked)**
|
||||||
|
|
||||||
Easiest fix: download the models on the host instead of inside the container — they land in `./data/`, which is already bind-mounted into the container, so it picks them up with no rebuild:
|
`install-local-gpu.sh` and `bring-up-local-gpu.sh` already run this for you automatically on every start, so you normally don't need to think about it. If a model still didn't download (no network at the time, etc.), re-run it manually — it lands in `./data/`, which is already bind-mounted into the container, so it's picked up with no rebuild:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./prefetch-models.sh # SAM + U2Net + BEN2 + BiRefNet-HR (~1.5GB)
|
./prefetch-models.sh # SAM + U2Net + BEN2 + BiRefNet-HR (~1.5GB)
|
||||||
|
|||||||
@@ -4,9 +4,11 @@
|
|||||||
# Run this each time you want to start the app.
|
# Run this each time you want to start the app.
|
||||||
# Run ./install-local-gpu.sh once first on a new machine.
|
# Run ./install-local-gpu.sh once first on a new machine.
|
||||||
#
|
#
|
||||||
# If models fail to download inside the container (DNS/firewall blocked),
|
# Before starting, this fetches any missing models on the host (outside
|
||||||
# run ./prefetch-models.sh first — it downloads them on the host into
|
# Docker) via ./prefetch-models.sh — in-container DNS/network is unreliable
|
||||||
# ./data/, which this container already bind-mounts, so no rebuild needed.
|
# on some hosts, so this is the default now, not a manual troubleshooting
|
||||||
|
# step. It never blocks startup: if it fails (no network, no python3, etc.)
|
||||||
|
# the container still starts and falls back to its own in-container download.
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# ./bring-up-local-gpu.sh # start (detached, rebuild if needed)
|
# ./bring-up-local-gpu.sh # start (detached, rebuild if needed)
|
||||||
@@ -29,6 +31,9 @@ cd "$(dirname "$0")"
|
|||||||
mkdir -p data/models data/hf_cache data/projects data/patches
|
mkdir -p data/models data/hf_cache data/projects data/patches
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
|
# Best-effort: fetch any missing models on the host first (see header).
|
||||||
|
./prefetch-models.sh --sdxl \
|
||||||
|
|| echo "⚠ Model prefetch had failures (see above) — continuing anyway, the container will retry in-container."
|
||||||
exec docker compose -f docker-compose.gpu.yml up -d --build
|
exec docker compose -f docker-compose.gpu.yml up -d --build
|
||||||
else
|
else
|
||||||
exec docker compose -f docker-compose.gpu.yml "$@"
|
exec docker compose -f docker-compose.gpu.yml "$@"
|
||||||
|
|||||||
+22
-3
@@ -170,12 +170,31 @@ else
|
|||||||
echo " Minimum driver version: 525"
|
echo " Minimum driver version: 525"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ── 6. Prefetch all AI models (host-side, outside Docker) ───────────────────
|
||||||
|
# In-container DNS/network is unreliable on some hosts, so downloading on the
|
||||||
|
# host up front (including SDXL/inpaint, ~13GB) is the default now rather
|
||||||
|
# than a manual troubleshooting step. Best-effort: this script must finish
|
||||||
|
# (and leave the GPU/Docker setup done) even if prefetch fails outright.
|
||||||
|
# Run as the real invoking user, not root, so downloaded files (and any
|
||||||
|
# `pip install --user` side effects) end up owned by that user — this script
|
||||||
|
# itself is already running as root via the sudo re-exec above.
|
||||||
|
echo ""
|
||||||
|
echo "Prefetching AI models (this can take a while for SDXL, ~13GB)..."
|
||||||
|
if [ -n "${SUDO_USER:-}" ]; then
|
||||||
|
sudo -u "$SUDO_USER" -H "$REPO_DIR/prefetch-models.sh" --sdxl \
|
||||||
|
|| echo "⚠ Model prefetch had failures (see above) — continuing anyway, the container will retry in-container."
|
||||||
|
else
|
||||||
|
"$REPO_DIR/prefetch-models.sh" --sdxl \
|
||||||
|
|| echo "⚠ Model prefetch had failures (see above) — continuing anyway, the container will retry in-container."
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "=================================================="
|
echo "=================================================="
|
||||||
echo " Setup complete."
|
echo " Setup complete."
|
||||||
echo " Start the app with: ./bring-up-local-gpu.sh"
|
echo " Start the app with: ./bring-up-local-gpu.sh"
|
||||||
echo ""
|
echo ""
|
||||||
echo " If models fail to download inside the container (DNS/firewall"
|
echo " Models are prefetched automatically by this script and by"
|
||||||
echo " blocked), fetch them on the host first instead:"
|
echo " bring-up-local-gpu.sh on every start. If any failed above (no"
|
||||||
echo " ./prefetch-models.sh"
|
echo " network, etc.), re-run manually any time:"
|
||||||
|
echo " ./prefetch-models.sh --sdxl"
|
||||||
echo "=================================================="
|
echo "=================================================="
|
||||||
|
|||||||
Reference in New Issue
Block a user