mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-11-28 19:16:33 +00:00
ci: build portable packages with GPU backends (Windows CUDA 12 and Vulkan, Linux Vulkan)
The portable workflow only built CPU packages, so a downloaded Windows zip
could never use the GPU ("sd-server detects only the CPU"). Mirror the
configuration already proven by build.yml and add the GPU modules:
- windows-x86_64: CPU + Vulkan (NVIDIA, AMD, Intel)
- windows-x86_64-cuda12: CPU + CUDA 12 with cudart/cublas/cublasLt bundled,
so only the NVIDIA driver is needed on the target machine
- linux-x86_64: CPU + Vulkan, with an $ORIGIN rpath so the unpacked zip finds
its shared libraries
- darwin-arm64 unchanged (Metal)
Windows now builds with cl.exe, /bigobj and the shared stable-diffusion
library like build.yml; the server frontend is built as in the main CI.
A manual run can select the packages and the CUDA architectures (a single
architecture shortens the CUDA build a lot). A smoke test runs
"sd-cli --list-devices" on every package, and the release is attached by one
job after all packages succeeded instead of by racing matrix jobs.
package_portable.sh takes PORTABLE_VARIANT (zip name and LEGGIMI wording) and
PORTABLE_REQUIRE_BACKENDS, and refuses to create a GPU package whose backend
module (or, on Windows, CUDA runtime DLLs) is missing.
Claude-Session: https://claude.ai/code/session_01EhZzDBkuuMp1jBf4WtEySC
This commit is contained in:
parent
9b4ff13d52
commit
df821e6b5c
5 changed files with 338 additions and 47 deletions
237
.github/workflows/release-portable.yml
vendored
237
.github/workflows/release-portable.yml
vendored
|
|
@ -1,60 +1,222 @@
|
|||
name: Release portable package
|
||||
|
||||
# Builds relocatable packages with dynamic ggml backends
|
||||
# (see docs/build.md, "Build a portable package").
|
||||
# Builds relocatable packages with dynamic ggml backends (see docs/build.md,
|
||||
# "Build a portable package"). Every package carries the CPU backend plus the
|
||||
# GPU module listed below. A module whose driver is missing on the user's
|
||||
# machine is skipped at runtime, so the same zip still runs without a GPU.
|
||||
#
|
||||
# linux-x86_64 CPU + Vulkan
|
||||
# darwin-arm64 CPU + Metal
|
||||
# windows-x86_64 CPU + Vulkan (NVIDIA, AMD and Intel GPUs)
|
||||
# windows-x86_64-cuda12 CPU + CUDA 12 (NVIDIA), CUDA runtime DLLs included
|
||||
#
|
||||
# Run it by hand from the Actions tab (on any branch) or push a "portable-v*"
|
||||
# tag, which also attaches the zips to a release.
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
targets:
|
||||
description: "Packages to build: 'all' or a comma-separated list of the names above"
|
||||
type: string
|
||||
default: all
|
||||
cuda_architectures:
|
||||
description: "CUDA architectures of the cuda12 package (a single one, such as 86, builds much faster)"
|
||||
type: string
|
||||
default: "61;70;75;80;86;89;90;100;120"
|
||||
push:
|
||||
tags:
|
||||
- "portable-v*"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
plan:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
include: ${{ steps.plan.outputs.include }}
|
||||
steps:
|
||||
- name: Select the packages
|
||||
id: plan
|
||||
shell: bash
|
||||
env:
|
||||
TARGETS: ${{ inputs.targets }}
|
||||
CUDA_ARCHITECTURES: ${{ inputs.cuda_architectures }}
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
packages = [
|
||||
{"name": "linux-x86_64", "os": "ubuntu-latest", "gpu": "vulkan", "variant": "vulkan"},
|
||||
{"name": "darwin-arm64", "os": "macos-14", "gpu": "metal", "variant": "metal"},
|
||||
{"name": "windows-x86_64", "os": "windows-2022", "gpu": "vulkan", "variant": "vulkan"},
|
||||
{"name": "windows-x86_64-cuda12", "os": "windows-2022", "gpu": "cuda", "variant": "cuda12"},
|
||||
]
|
||||
|
||||
wanted = [w.strip() for w in os.environ.get("TARGETS", "").split(",") if w.strip()]
|
||||
if not wanted or "all" in wanted:
|
||||
chosen = packages
|
||||
else:
|
||||
known = [p["name"] for p in packages]
|
||||
unknown = [w for w in wanted if w not in known]
|
||||
if unknown:
|
||||
sys.exit("unknown package(s): %s (known: %s)" % (", ".join(unknown), ", ".join(known)))
|
||||
chosen = [p for p in packages if p["name"] in wanted]
|
||||
|
||||
# Same default as the workflow_dispatch input; tag pushes have no inputs.
|
||||
archs = os.environ.get("CUDA_ARCHITECTURES", "").strip() or "61;70;75;80;86;89;90;100;120"
|
||||
arch = r"[0-9]+[a-z]?(-real|-virtual)?"
|
||||
if not re.fullmatch("%s(;%s)*" % (arch, arch), archs):
|
||||
sys.exit("invalid CUDA architectures: " + archs)
|
||||
for p in chosen:
|
||||
if p["gpu"] == "cuda":
|
||||
p["cuda_architectures"] = archs
|
||||
|
||||
print(json.dumps(chosen, indent=2))
|
||||
with open(os.environ["GITHUB_OUTPUT"], "a") as out:
|
||||
out.write("include=" + json.dumps(chosen) + "\n")
|
||||
PY
|
||||
|
||||
package:
|
||||
needs: plan
|
||||
name: ${{ matrix.name }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
name: linux-x86_64
|
||||
cmake_args: >-
|
||||
-DGGML_CPU_ALL_VARIANTS=ON -DGGML_NATIVE=OFF
|
||||
- os: macos-14
|
||||
name: darwin-arm64
|
||||
cmake_args: >-
|
||||
-DSD_METAL=ON
|
||||
- os: windows-latest
|
||||
name: windows-x86_64
|
||||
cmake_args: >-
|
||||
-DGGML_CPU_ALL_VARIANTS=ON -DGGML_NATIVE=OFF
|
||||
include: ${{ fromJSON(needs.plan.outputs.include) }}
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
submodules: recursive
|
||||
|
||||
- name: Checkout required submodules
|
||||
run: git submodule update --init ggml thirdparty/libwebp thirdparty/libwebm
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10.15.1
|
||||
|
||||
- name: Install dependencies (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential ninja-build libvulkan-dev glslc spirv-headers
|
||||
|
||||
- name: Install dependencies (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install ninja
|
||||
|
||||
- name: Install the CUDA toolkit (Windows)
|
||||
id: cuda-toolkit
|
||||
if: runner.os == 'Windows' && matrix.gpu == 'cuda'
|
||||
uses: Jimver/cuda-toolkit@v0.2.22
|
||||
with:
|
||||
cuda: "12.8.1"
|
||||
method: "network"
|
||||
sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
|
||||
|
||||
- name: Install the Vulkan SDK (Windows)
|
||||
if: runner.os == 'Windows' && matrix.gpu == 'vulkan'
|
||||
shell: pwsh
|
||||
env:
|
||||
VULKAN_VERSION: 1.4.328.1
|
||||
run: |
|
||||
$installer = Join-Path $env:RUNNER_TEMP 'VulkanSDK-Installer.exe'
|
||||
curl.exe -o $installer -L "https://sdk.lunarg.com/sdk/download/${env:VULKAN_VERSION}/windows/vulkansdk-windows-X64-${env:VULKAN_VERSION}.exe"
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
Start-Process -FilePath $installer -ArgumentList '--accept-licenses', '--default-answer', '--confirm-command', 'install' -Wait
|
||||
$sdk = "C:\VulkanSDK\${env:VULKAN_VERSION}"
|
||||
for ($i = 0; $i -lt 60 -and -not ((Test-Path "$sdk\Bin\glslc.exe") -and (Test-Path "$sdk\Lib\vulkan-1.lib")); $i++) { Start-Sleep -Seconds 5 }
|
||||
if (-not (Test-Path "$sdk\Bin\glslc.exe")) { throw "The Vulkan SDK was not installed in $sdk" }
|
||||
Add-Content $env:GITHUB_ENV "VULKAN_SDK=$sdk"
|
||||
Add-Content $env:GITHUB_PATH "$sdk\Bin"
|
||||
|
||||
- name: Setup MSVC (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
|
||||
- name: Configure
|
||||
shell: bash
|
||||
run: >-
|
||||
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||
-DSD_BUILD_SHARED_GGML_LIB=ON -DBUILD_SHARED_LIBS=ON -DGGML_BACKEND_DL=ON
|
||||
${{ matrix.cmake_args }}
|
||||
- name: Configure and build (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
env:
|
||||
GPU: ${{ matrix.gpu }}
|
||||
CUDA_ARCHITECTURES: ${{ matrix.cuda_architectures }}
|
||||
run: |
|
||||
$cmakeArgs = @(
|
||||
'-G', 'Ninja',
|
||||
'-DCMAKE_BUILD_TYPE=Release',
|
||||
'-DCMAKE_C_COMPILER=cl.exe',
|
||||
'-DCMAKE_CXX_COMPILER=cl.exe',
|
||||
'-DCMAKE_CXX_FLAGS=/bigobj',
|
||||
'-DGGML_NATIVE=OFF',
|
||||
'-DSD_BUILD_SHARED_LIBS=ON',
|
||||
'-DSD_BUILD_SHARED_GGML_LIB=ON',
|
||||
'-DGGML_BACKEND_DL=ON',
|
||||
'-DGGML_CPU_ALL_VARIANTS=ON'
|
||||
)
|
||||
if ($env:GPU -eq 'vulkan') { $cmakeArgs += '-DSD_VULKAN=ON' }
|
||||
if ($env:GPU -eq 'cuda') {
|
||||
$cmakeArgs += '-DSD_CUDA=ON'
|
||||
$cmakeArgs += "-DCMAKE_CUDA_ARCHITECTURES=$env:CUDA_ARCHITECTURES"
|
||||
}
|
||||
cmake -S . -B build @cmakeArgs
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
cmake --build build
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
|
||||
- name: Build
|
||||
- name: Configure and build (Linux, macOS)
|
||||
if: runner.os != 'Windows'
|
||||
shell: bash
|
||||
run: cmake --build build -j
|
||||
env:
|
||||
GPU: ${{ matrix.gpu }}
|
||||
run: |
|
||||
args=(
|
||||
-G Ninja
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
-DSD_BUILD_SHARED_LIBS=ON
|
||||
-DSD_BUILD_SHARED_GGML_LIB=ON
|
||||
-DBUILD_SHARED_LIBS=ON
|
||||
-DGGML_BACKEND_DL=ON
|
||||
)
|
||||
case "$GPU" in
|
||||
vulkan) args+=(-DSD_VULKAN=ON) ;;
|
||||
metal) args+=(-DSD_METAL=ON) ;;
|
||||
esac
|
||||
if [ "$RUNNER_OS" = Linux ]; then
|
||||
# $ORIGIN keeps the shared libraries found after the zip is unpacked elsewhere.
|
||||
args+=(-DGGML_NATIVE=OFF -DGGML_CPU_ALL_VARIANTS=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON '-DCMAKE_INSTALL_RPATH=$ORIGIN')
|
||||
fi
|
||||
cmake -S . -B build "${args[@]}"
|
||||
cmake --build build
|
||||
|
||||
- name: Bundle the CUDA runtime (Windows)
|
||||
if: runner.os == 'Windows' && matrix.gpu == 'cuda'
|
||||
shell: pwsh
|
||||
env:
|
||||
CUDA_ROOT: ${{ steps.cuda-toolkit.outputs.CUDA_PATH }}
|
||||
run: |
|
||||
foreach ($pattern in 'cudart64_*.dll', 'cublas64_*.dll', 'cublasLt64_*.dll') {
|
||||
$files = @(Get-ChildItem -Path (Join-Path $env:CUDA_ROOT 'bin') -Filter $pattern)
|
||||
if ($files.Count -eq 0) { throw "CUDA runtime library not found: $pattern in $env:CUDA_ROOT" }
|
||||
Copy-Item -Path $files.FullName -Destination 'build\bin\'
|
||||
}
|
||||
|
||||
- name: Smoke test
|
||||
shell: bash
|
||||
run: |
|
||||
exe=build/bin/sd-cli
|
||||
[ -x "$exe" ] || exe="$exe.exe"
|
||||
"$exe" --list-devices
|
||||
|
||||
- name: Security smoke test
|
||||
if: runner.os != 'Windows'
|
||||
|
|
@ -63,15 +225,32 @@ jobs:
|
|||
|
||||
- name: Package
|
||||
shell: bash
|
||||
env:
|
||||
PORTABLE_VARIANT: ${{ matrix.variant }}
|
||||
PORTABLE_REQUIRE_BACKENDS: ${{ matrix.gpu }}
|
||||
run: ./scripts/package_portable.sh build dist
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: portable-${{ matrix.name }}
|
||||
path: dist/*.zip
|
||||
compression-level: 0
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Attach to release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
release:
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
needs: package
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: portable-*
|
||||
path: dist
|
||||
merge-multiple: true
|
||||
|
||||
- name: Attach to the release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: dist/*.zip
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ progetto originale. Modifiche del fork di **Francesco Simeoni**
|
|||
- **Fallback CPU automatico**: se il backend richiesto manca o non si inizializza, il contesto degrada alla CPU invece di fallire
|
||||
- **Memory guard** (`--memory-guard 90`): sopra la soglia riduce la pressione di memoria (eviction dei pesi, prefetch sospeso) prima dell'out-of-memory; sulla CPU misura la RAM di sistema
|
||||
- **Server robusto**: parte anche senza modello, autenticazione opzionale (`--api-key`) e allowlist CORS (`--cors-origins`)
|
||||
- **Pacchetto portabile**: backend ggml come librerie dinamiche caricate a runtime — un solo zip per macchine vecchie e nuove (`scripts/package_portable.sh`)
|
||||
- **Pacchetto portabile**: backend ggml come librerie dinamiche caricate a runtime — un solo zip per macchine vecchie e nuove (`scripts/package_portable.sh`); pacchetti con GPU pronti: Windows CUDA 12 (NVIDIA, DLL incluse), Windows/Linux Vulkan, macOS Metal
|
||||
- **Suite di test di sicurezza** in [test/](./test/): file modello ostili, fuzzing, sanitizer
|
||||
|
||||
Tutti i dettagli, passo per passo: **[guida completa in italiano](./docs/integrazione_progetti.md)**
|
||||
|
|
|
|||
|
|
@ -102,7 +102,28 @@ at runtime, which keeps the same package working on very old CPUs.
|
|||
|
||||
`scripts/package_portable.sh <build_dir>` collects the executables, backend
|
||||
modules, and license files from a portable build into a relocatable zip under
|
||||
`dist/`.
|
||||
`dist/`. Two environment variables describe a GPU package:
|
||||
`PORTABLE_VARIANT=cuda12|vulkan|metal` (zip name suffix and README wording) and
|
||||
`PORTABLE_REQUIRE_BACKENDS=cuda|vulkan|metal`, which makes the script fail when
|
||||
that backend module is not in the build (on Windows, also when the CUDA runtime
|
||||
DLLs `cudart64_*`, `cublas64_*` and `cublasLt64_*` are missing) instead of
|
||||
shipping a package that silently runs on the CPU.
|
||||
|
||||
The GitHub Actions workflow `.github/workflows/release-portable.yml` builds
|
||||
these packages, each with the CPU backend plus one GPU module:
|
||||
|
||||
| Package | GPU backend | Notes |
|
||||
|---|---|---|
|
||||
| `linux-x86_64` | Vulkan | needs the Vulkan loader (`libvulkan.so.1`) at runtime |
|
||||
| `darwin-arm64` | Metal | Apple Silicon |
|
||||
| `windows-x86_64` | Vulkan | NVIDIA, AMD and Intel GPUs; `vulkan-1.dll` comes with the GPU driver |
|
||||
| `windows-x86_64-cuda12` | CUDA 12 | NVIDIA only; the CUDA runtime DLLs are bundled, only the NVIDIA driver is needed |
|
||||
|
||||
Start it from the Actions tab ("Run workflow", any branch) or push a tag
|
||||
`portable-v*`, which also attaches the zips to a release. The manual run takes
|
||||
two inputs: `targets` (`all` or a comma-separated list of the package names
|
||||
above) and `cuda_architectures` (default `61;70;75;80;86;89;90;100;120`; a single
|
||||
architecture, e.g. `86` for GeForce RTX 30 series, shortens the CUDA build a lot).
|
||||
|
||||
## Build with OpenBLAS
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ controllato:
|
|||
| Server senza modello | `sd-server` parte anche senza `-m`: device e upscale funzionano, la generazione risponde con un errore chiaro | **attivo** |
|
||||
| Autenticazione server | `--api-key` (Bearer o `X-API-Key`) e allowlist CORS `--cors-origins` | **disattivi** |
|
||||
| Pacchetto portabile | backend ggml come librerie dinamiche caricate a runtime: un solo pacchetto, ogni macchina usa ciò che ha | opzionale in build |
|
||||
| Release automatiche | workflow `release-portable.yml`: zip per Linux/macOS/Windows a ogni tag `portable-v*` | su tag |
|
||||
| Release automatiche | workflow `release-portable.yml`: zip con GPU (Windows CUDA 12 e Vulkan, Linux Vulkan, macOS Metal) a ogni tag `portable-v*` o avvio manuale | su tag |
|
||||
| Suite di test | `test/`: smoke di sicurezza, robustezza API, fuzzer del caricamento modelli | manuale |
|
||||
|
||||
L'unico cambio di comportamento predefinito rispetto a upstream è il fallback
|
||||
|
|
@ -371,11 +371,38 @@ con il generatore Visual Studio finiscono invece in `build/bin/Release` e lo
|
|||
script non li trova. Il pacchetto è rilocabile all'interno della stessa
|
||||
piattaforma e architettura: si scompatta e si usa, senza installazione.
|
||||
Il workflow GitHub Actions `release-portable.yml` produce automaticamente gli
|
||||
zip per Linux x86-64, macOS arm64 e Windows x86-64 (con varianti CPU
|
||||
SSE/AVX/AVX2/AVX-512 su x86 per le macchine più vecchie) a ogni tag
|
||||
`portable-v*` o avvio manuale. I pacchetti di release non sono un singolo
|
||||
binario multipiattaforma: scegliere quello corrispondente al sistema operativo
|
||||
e all'architettura del computer di destinazione.
|
||||
zip (con varianti CPU SSE/AVX/AVX2/AVX-512 su x86 per le macchine più vecchie)
|
||||
a ogni tag `portable-v*` o avvio manuale. I pacchetti di release non sono un
|
||||
singolo binario multipiattaforma: scegliere quello corrispondente al sistema
|
||||
operativo e all'architettura del computer di destinazione.
|
||||
|
||||
#### Pacchetti con GPU già pronti
|
||||
|
||||
| Pacchetto | Backend GPU | Quando sceglierlo |
|
||||
|---|---|---|
|
||||
| `windows-x86_64-cuda12` | CUDA 12 | Windows con scheda **NVIDIA**: è il più veloce su NVIDIA. Le DLL di CUDA (`cudart`, `cublas`, `cublasLt`) sono già nello zip: serve solo un driver NVIDIA aggiornato |
|
||||
| `windows-x86_64` | Vulkan | Windows con GPU AMD, Intel o NVIDIA; Vulkan arriva con il driver grafico. Senza driver Vulkan il programma usa la CPU |
|
||||
| `linux-x86_64` | Vulkan | Linux con driver grafico che fornisce `libvulkan.so.1` |
|
||||
| `darwin-arm64` | Metal | Mac con Apple Silicon |
|
||||
|
||||
Ogni pacchetto contiene anche il backend CPU: se il modulo GPU non si carica
|
||||
(driver assente o troppo vecchio) il programma parte comunque sulla CPU, e il
|
||||
log spiega perché il modulo GPU è stato scartato. Non servono SDK o compilatori
|
||||
sulla macchina di destinazione. Su Windows serve il Microsoft Visual C++
|
||||
Redistributable 2015-2022 (x64), di solito già presente.
|
||||
|
||||
Per ottenerli senza tag: scheda **Actions** del repository, workflow
|
||||
"Release portable package", **Run workflow**, scegliendo il ramo. Gli ingressi
|
||||
sono `targets` (`all` oppure l'elenco dei nomi sopra, separati da virgola) e
|
||||
`cuda_architectures` (predefinito: tutte le generazioni NVIDIA da Pascal a
|
||||
Blackwell; per una scheda sola, per esempio `86` per le GeForce RTX serie 30,
|
||||
la compilazione CUDA è molto più breve). Gli zip compaiono tra gli artefatti
|
||||
dell'esecuzione (`portable-<nome>`) e, con un tag, nella release. Lo script di
|
||||
packaging rifiuta di creare lo zip se il modulo GPU (o le DLL di CUDA) mancano,
|
||||
così un pacchetto "con GPU" non può in silenzio funzionare solo sulla CPU.
|
||||
|
||||
Verifica dopo lo scompattamento: `sd-cli --list-devices` deve elencare, oltre
|
||||
alla CPU, una riga di tipo `gpu` (o `igpu`).
|
||||
|
||||
## 3. Come collegarlo a un progetto
|
||||
|
||||
|
|
@ -583,9 +610,9 @@ per cui è stato creato, non universale.
|
|||
|
||||
| Piattaforma del pacchetto di release | Architettura prevista | Note |
|
||||
|---|---|---|
|
||||
| Linux | x86-64 | La release include varianti CPU x86 selezionabili. Non abilita CUDA o Vulkan. La compatibilità con distribuzioni Linux meno recenti dipende anche dalla versione di glibc e dalle librerie di sistema: verificare sul sistema minimo di destinazione. |
|
||||
| Linux | x86-64 | La release include varianti CPU x86 selezionabili e il backend Vulkan (serve `libvulkan.so.1` sulla macchina); CUDA non è incluso. La compatibilità con distribuzioni Linux meno recenti dipende anche dalla versione di glibc e dalle librerie di sistema: verificare sul sistema minimo di destinazione. |
|
||||
| macOS | arm64 (Apple Silicon) | La release automatica corrente è per macOS arm64; non è un binario Intel/x86-64. Include Metal, che richiede hardware e sistema Apple compatibili. |
|
||||
| Windows | x86-64 | La release include varianti CPU x86 selezionabili, ma non abilita CUDA o Vulkan. Verificare la presenza dei runtime richiesti dal compilatore; driver GPU e backend GPU vanno predisposti separatamente nelle build personalizzate. |
|
||||
| Windows | x86-64 | Due pacchetti: `windows-x86_64` (CPU + Vulkan, per GPU NVIDIA, AMD e Intel) e `windows-x86_64-cuda12` (CPU + CUDA 12 per NVIDIA, con le DLL di CUDA incluse). Entrambi richiedono il driver grafico aggiornato e il Visual C++ Redistributable 2015-2022 (x64). |
|
||||
|
||||
Questa tabella descrive gli artefatti generati dall'attuale workflow di release,
|
||||
non una garanzia di compatibilità con tutte le versioni storiche dei sistemi
|
||||
|
|
@ -830,6 +857,12 @@ sincronizzazioni future.
|
|||
con binari, moduli backend, licenze, LEGGIMI) e workflow
|
||||
`.github/workflows/release-portable.yml` per Linux/macOS/Windows su tag
|
||||
`portable-v*`.
|
||||
11. **Pacchetti portabili con GPU** — il workflow produce ora anche
|
||||
`windows-x86_64-cuda12` (CUDA 12 con le DLL runtime incluse) e include
|
||||
Vulkan in `windows-x86_64` e `linux-x86_64`; opzioni, flag di
|
||||
compilazione e SDK allineati alla CI principale; avvio manuale con scelta
|
||||
dei pacchetti e delle architetture CUDA; release creata da un job unico;
|
||||
lo script di packaging verifica che il modulo GPU sia nello zip.
|
||||
|
||||
Passaggi previsti e non ancora svolti: collaudo del workflow di release sui
|
||||
runner GitHub, generazione con un modello reale (inclusa la memory guard sotto
|
||||
|
|
|
|||
|
|
@ -2,6 +2,14 @@
|
|||
# Create a relocatable distribution package from a portable build
|
||||
# (see docs/build.md, "Build a portable package").
|
||||
# Usage: scripts/package_portable.sh [build_dir] [output_dir]
|
||||
#
|
||||
# Environment:
|
||||
# PORTABLE_VARIANT suffix of the zip name and wording of LEGGIMI.txt:
|
||||
# cuda12, vulkan or metal (empty: CPU only)
|
||||
# PORTABLE_REQUIRE_BACKENDS space/comma separated ggml backends (cuda, vulkan,
|
||||
# metal) whose module must be in the build; the
|
||||
# script fails instead of shipping a package that
|
||||
# would silently fall back to the CPU
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
|
|
@ -24,7 +32,8 @@ case "$(uname -s)" in
|
|||
*) os="$(uname -s | tr '[:upper:]' '[:lower:]')" ;;
|
||||
esac
|
||||
arch="$(uname -m)"
|
||||
name="diffusione-in-tempo-reale-${version}-${os}-${arch}"
|
||||
variant="${PORTABLE_VARIANT:-}"
|
||||
name="diffusione-in-tempo-reale-${version}-${os}-${arch}${variant:+-$variant}"
|
||||
stage="$(mktemp -d)/$name"
|
||||
mkdir -p "$stage/licenses" "$output_dir"
|
||||
trap 'rm -rf "$(dirname "$stage")"' EXIT
|
||||
|
|
@ -32,6 +41,53 @@ trap 'rm -rf "$(dirname "$stage")"' EXIT
|
|||
# Binaries plus every shared library/backend module next to them.
|
||||
cp -R "$build_dir/bin/." "$stage/"
|
||||
|
||||
missing=()
|
||||
required="${PORTABLE_REQUIRE_BACKENDS:-}"
|
||||
for backend in ${required//,/ }; do
|
||||
compgen -G "$stage/*ggml-$backend.*" >/dev/null || missing+=("ggml-$backend module")
|
||||
if [[ "$backend" == cuda && "$os" == windows ]]; then
|
||||
# ggml-cuda.dll cannot load on a machine without the CUDA toolkit
|
||||
# unless its runtime libraries sit next to it.
|
||||
for lib in cudart64_ cublas64_ cublasLt64_; do
|
||||
compgen -G "$stage/${lib}*.dll" >/dev/null || missing+=("${lib}*.dll")
|
||||
done
|
||||
fi
|
||||
done
|
||||
if ((${#missing[@]})); then
|
||||
echo "error: the package could not use its GPU backend; missing: ${missing[*]}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$variant" in
|
||||
cuda*) gpu_note="GPU: questo pacchetto usa CUDA 12 (schede NVIDIA). Serve solo il driver
|
||||
NVIDIA aggiornato: le DLL di CUDA (cudart, cublas) sono incluse e devono
|
||||
restare nella stessa cartella di sd-cli e sd-server." ;;
|
||||
vulkan) gpu_note="GPU: questo pacchetto usa Vulkan (schede NVIDIA, AMD, Intel). Serve il
|
||||
driver grafico aggiornato del produttore, che installa Vulkan insieme a se'." ;;
|
||||
metal) gpu_note="GPU: questo pacchetto usa Metal (Apple Silicon)." ;;
|
||||
*) gpu_note="GPU: questo pacchetto usa solo la CPU." ;;
|
||||
esac
|
||||
|
||||
help_note=""
|
||||
if [[ -n "$variant" ]]; then
|
||||
keep_files="i file ggml-*"
|
||||
if [[ "$variant" == cuda* ]]; then
|
||||
keep_files+=" e le DLL di CUDA"
|
||||
fi
|
||||
help_note="
|
||||
Se --list-devices mostra solo la CPU: aggiorna il driver della scheda video e
|
||||
non spostare ${keep_files} fuori dalla cartella degli
|
||||
eseguibili. Il programma scrive nel log perche' un modulo GPU non e' stato
|
||||
caricato.
|
||||
"
|
||||
fi
|
||||
if [[ "$os" == windows ]]; then
|
||||
help_note+="
|
||||
Su Windows serve anche Microsoft Visual C++ Redistributable 2015-2022 (x64),
|
||||
di solito gia' presente.
|
||||
"
|
||||
fi
|
||||
|
||||
cp LICENSE "$stage/"
|
||||
cp ggml/LICENSE "$stage/licenses/ggml.LICENSE"
|
||||
cp thirdparty/libwebp/COPYING "$stage/licenses/libwebp.COPYING" 2>/dev/null || true
|
||||
|
|
@ -40,16 +96,18 @@ cp thirdparty/oniguruma/COPYING "$stage/licenses/oniguruma.COPYING" 2>/dev/null
|
|||
cp thirdparty/utf8proc/LICENSE.md "$stage/licenses/utf8proc.LICENSE.md" 2>/dev/null || true
|
||||
|
||||
cat > "$stage/LEGGIMI.txt" <<EOF
|
||||
diffusione-in-tempo-reale ${version} (${os}/${arch})
|
||||
Pacchetto portabile: i backend (libggml-*) sono caricati a runtime, solo se
|
||||
diffusione-in-tempo-reale ${version} (${os}/${arch}${variant:+, $variant})
|
||||
Pacchetto portabile: i backend (ggml-*) sono caricati a runtime, solo se
|
||||
la macchina li supporta. Nessuna installazione richiesta.
|
||||
|
||||
Comandi principali:
|
||||
./sd-cli --list-devices elenca i dispositivi disponibili
|
||||
./sd-cli -m modello.safetensors -p "un gatto" genera un'immagine
|
||||
./sd-server avvia il server HTTP su 127.0.0.1:1234
|
||||
(parte anche senza modello)
|
||||
${gpu_note}
|
||||
|
||||
Comandi principali:
|
||||
sd-cli --list-devices elenca i dispositivi: deve comparire la GPU
|
||||
sd-cli -m modello.safetensors -p "un gatto" genera un'immagine
|
||||
sd-server avvia il server HTTP su 127.0.0.1:1234
|
||||
(parte anche senza modello)
|
||||
${help_note}
|
||||
Opzioni utili: --memory-guard 90 (protezione memoria), --max-vram,
|
||||
--params-backend disk (modelli piu' grandi della RAM/VRAM).
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue