forked from Akegarasu/lora-scripts
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathinstall.ps1
More file actions
62 lines (52 loc) · 2.65 KB
/
Copy pathinstall.ps1
File metadata and controls
62 lines (52 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
$Env:HF_HOME = "huggingface"
. "$PSScriptRoot\install_preflight.ps1"
function InstallFail {
Write-Output "Install failed."
Read-Host | Out-Null
Exit 1
}
if (-not (Test-InstallScriptFreshness)) { InstallFail }
if (-not (Test-InstallPython)) { InstallFail }
# Ensure the pinned vendor/sd-scripts submodule (Anima training engine) is
# present. Safe to run repeatedly; skips silently when not a git checkout.
if ((Test-Path -Path ".git") -or (Test-Path -Path ".git" -PathType Leaf)) {
Write-Output "Syncing git submodules (vendor/sd-scripts)..."
git submodule update --init --recursive
if ($LASTEXITCODE -ne 0) {
Write-Output "Warning: submodule init failed; Anima training may not start. Run 'git submodule update --init --recursive' manually."
}
}
if (!(Test-Path -Path "venv")) {
Write-Output "Creating venv for python..."
python -m venv venv
}
.\venv\Scripts\activate
Write-Output "Installing deps..."
# Always `python -m pip`, never bare `pip`. If `pip` is not resolvable (a venv
# created by uv has no pip shim, or PATH is odd) PowerShell raises a command-not-
# found error without touching $LASTEXITCODE, so the checks below would still see
# the 0 left by `python -m venv` and report "Install completed" over an empty venv.
python -m pip install --upgrade "pip>=23.1"
if ($LASTEXITCODE -ne 0) { Write-Output "pip upgrade failed. Check your network and retry."; InstallFail }
python -m pip install torch==2.7.0+cu128 torchvision==0.22.0+cu128 --index-url https://download.pytorch.org/whl/cu128
if ($LASTEXITCODE -ne 0) { Write-Output "torch install failed. Delete venv and retry."; InstallFail }
python -m pip install -U -I --no-deps xformers==0.0.30 --index-url https://download.pytorch.org/whl/cu128
if ($LASTEXITCODE -ne 0) { Write-Output "xformers install failed."; InstallFail }
python -m pip install --upgrade -r requirements.txt
if ($LASTEXITCODE -ne 0) { Write-Output "requirements install failed."; InstallFail }
Write-Output "Prefetching default WD tagger wd14-convnextv2-v2 (~388 MB)..."
python scripts/prefetch_default_tagger.py --if-missing --no-mirror
if ($LASTEXITCODE -ne 0) {
Write-Output "Warning: default tagger prefetch failed; it will download on first tag run."
}
Write-Output "Verifying the install..."
python -c "import torch; print('torch', torch.__version__)"
if ($LASTEXITCODE -ne 0) {
Write-Output "Verification failed: cannot import torch inside venv."
Write-Output "Scroll up for the pip error, or delete the venv folder and retry."
InstallFail
}
Write-Output "Install completed"
Write-Output ""
Write-Output "Optional: run install_flash_attn.bat to enable Flash Attention 2 acceleration."
Read-Host | Out-Null