mirror of
https://github.com/leejet/stable-diffusion.cpp
synced 2026-03-07 07:29:32 +01:00
696 lines
27 KiB
YAML
696 lines
27 KiB
YAML
name: CI
|
|
|
|
on:
|
|
workflow_dispatch: # allows manual triggering
|
|
inputs:
|
|
create_release:
|
|
description: "Create new release"
|
|
required: true
|
|
type: boolean
|
|
push:
|
|
branches:
|
|
- master
|
|
- ci
|
|
paths:
|
|
[
|
|
".github/workflows/**",
|
|
"**/CMakeLists.txt",
|
|
"**/Makefile",
|
|
"**/*.h",
|
|
"**/*.hpp",
|
|
"**/*.c",
|
|
"**/*.cpp",
|
|
"**/*.cu",
|
|
]
|
|
pull_request:
|
|
types: [opened, synchronize, reopened]
|
|
paths:
|
|
[
|
|
"**/CMakeLists.txt",
|
|
"**/Makefile",
|
|
"**/*.h",
|
|
"**/*.hpp",
|
|
"**/*.c",
|
|
"**/*.cpp",
|
|
"**/*.cu",
|
|
]
|
|
|
|
env:
|
|
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
ubuntu-latest-cmake:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Clone
|
|
id: checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Dependencies
|
|
id: depends
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install build-essential
|
|
|
|
- name: Build
|
|
id: cmake_build
|
|
run: |
|
|
mkdir build
|
|
cd build
|
|
cmake .. -DGGML_AVX2=ON -DSD_BUILD_SHARED_LIBS=ON
|
|
cmake --build . --config Release
|
|
|
|
- name: Get commit hash
|
|
id: commit
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
uses: pr-mpt/actions-commit-hash@v2
|
|
|
|
- name: Fetch system info
|
|
id: system-info
|
|
run: |
|
|
echo "CPU_ARCH=`uname -m`" >> "$GITHUB_OUTPUT"
|
|
echo "OS_NAME=`lsb_release -s -i`" >> "$GITHUB_OUTPUT"
|
|
echo "OS_VERSION=`lsb_release -s -r`" >> "$GITHUB_OUTPUT"
|
|
echo "OS_TYPE=`uname -s`" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Pack artifacts
|
|
id: pack_artifacts
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
run: |
|
|
cp ggml/LICENSE ./build/bin/ggml.txt
|
|
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
|
|
zip -j sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip ./build/bin/*
|
|
|
|
- name: Upload artifacts
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip
|
|
path: |
|
|
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip
|
|
|
|
ubuntu-latest-cmake-vulkan:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Clone
|
|
id: checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Dependencies
|
|
id: depends
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install build-essential libvulkan-dev glslc
|
|
|
|
- name: Build
|
|
id: cmake_build
|
|
run: |
|
|
mkdir build
|
|
cd build
|
|
cmake .. -DSD_BUILD_SHARED_LIBS=ON -DSD_VULKAN=ON
|
|
cmake --build . --config Release
|
|
|
|
- name: Get commit hash
|
|
id: commit
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
uses: pr-mpt/actions-commit-hash@v2
|
|
|
|
- name: Fetch system info
|
|
id: system-info
|
|
run: |
|
|
echo "CPU_ARCH=`uname -m`" >> "$GITHUB_OUTPUT"
|
|
echo "OS_NAME=`lsb_release -s -i`" >> "$GITHUB_OUTPUT"
|
|
echo "OS_VERSION=`lsb_release -s -r`" >> "$GITHUB_OUTPUT"
|
|
echo "OS_TYPE=`uname -s`" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Pack artifacts
|
|
id: pack_artifacts
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
run: |
|
|
cp ggml/LICENSE ./build/bin/ggml.txt
|
|
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
|
|
zip -j sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-vulkan.zip ./build/bin/*
|
|
|
|
- name: Upload artifacts
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-vulkan.zip
|
|
path: |
|
|
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-vulkan.zip
|
|
|
|
build-and-push-docker-images:
|
|
name: Build and push container images
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
id-token: write
|
|
attestations: write
|
|
artifact-metadata: write
|
|
|
|
strategy:
|
|
matrix:
|
|
variant: [musa, sycl, vulkan]
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Get commit hash
|
|
id: commit
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
uses: pr-mpt/actions-commit-hash@v2
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to the container registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
|
|
- name: Free Disk Space (Ubuntu)
|
|
uses: jlumbroso/free-disk-space@v1.3.1
|
|
with:
|
|
# this might remove tools that are actually needed,
|
|
# if set to "true" but frees about 6 GB
|
|
tool-cache: false
|
|
|
|
- name: Build and push Docker image
|
|
id: build-push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
platforms: linux/amd64
|
|
push: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
file: Dockerfile.${{ matrix.variant }}
|
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ matrix.variant }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
annotations: ${{ steps.meta.outputs.annotations }}
|
|
|
|
macOS-latest-cmake:
|
|
runs-on: macos-latest
|
|
|
|
steps:
|
|
- name: Clone
|
|
id: checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Dependencies
|
|
id: depends
|
|
run: |
|
|
brew install zip
|
|
|
|
- name: Build
|
|
id: cmake_build
|
|
run: |
|
|
sysctl -a
|
|
mkdir build
|
|
cd build
|
|
cmake .. -DGGML_AVX2=ON -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DSD_BUILD_SHARED_LIBS=ON
|
|
cmake --build . --config Release
|
|
|
|
- name: Get commit hash
|
|
id: commit
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
uses: pr-mpt/actions-commit-hash@v2
|
|
|
|
- name: Fetch system info
|
|
id: system-info
|
|
run: |
|
|
echo "CPU_ARCH=`uname -m`" >> "$GITHUB_OUTPUT"
|
|
echo "OS_NAME=`sw_vers -productName`" >> "$GITHUB_OUTPUT"
|
|
echo "OS_VERSION=`sw_vers -productVersion`" >> "$GITHUB_OUTPUT"
|
|
echo "OS_TYPE=`uname -s`" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Pack artifacts
|
|
id: pack_artifacts
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
run: |
|
|
cp ggml/LICENSE ./build/bin/ggml.txt
|
|
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
|
|
zip -j sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip ./build/bin/*
|
|
|
|
- name: Upload artifacts
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip
|
|
path: |
|
|
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-${{ steps.system-info.outputs.OS_NAME }}-${{ steps.system-info.outputs.OS_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}.zip
|
|
|
|
windows-latest-cmake:
|
|
runs-on: windows-2022
|
|
|
|
env:
|
|
VULKAN_VERSION: 1.4.328.1
|
|
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- build: "noavx"
|
|
defines: "-DGGML_NATIVE=OFF -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF -DSD_BUILD_SHARED_LIBS=ON"
|
|
- build: "avx2"
|
|
defines: "-DGGML_NATIVE=OFF -DGGML_AVX2=ON -DSD_BUILD_SHARED_LIBS=ON"
|
|
- build: "avx"
|
|
defines: "-DGGML_NATIVE=OFF -DGGML_AVX=ON -DGGML_AVX2=OFF -DSD_BUILD_SHARED_LIBS=ON"
|
|
- build: "avx512"
|
|
defines: "-DGGML_NATIVE=OFF -DGGML_AVX512=ON -DGGML_AVX=ON -DGGML_AVX2=ON -DSD_BUILD_SHARED_LIBS=ON"
|
|
- build: "cuda12"
|
|
defines: "-DSD_CUDA=ON -DSD_BUILD_SHARED_LIBS=ON -DCMAKE_CUDA_ARCHITECTURES='61;70;75;80;86;89;90;100;120' -DCMAKE_CUDA_FLAGS='-Xcudafe \"--diag_suppress=177\" -Xcudafe \"--diag_suppress=550\"'"
|
|
- build: "vulkan"
|
|
defines: "-DSD_VULKAN=ON -DSD_BUILD_SHARED_LIBS=ON"
|
|
steps:
|
|
- name: Clone
|
|
id: checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Install cuda-toolkit
|
|
id: cuda-toolkit
|
|
if: ${{ matrix.build == 'cuda12' }}
|
|
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 Vulkan SDK
|
|
id: get_vulkan
|
|
if: ${{ matrix.build == 'vulkan' }}
|
|
run: |
|
|
curl.exe -o $env:RUNNER_TEMP/VulkanSDK-Installer.exe -L "https://sdk.lunarg.com/sdk/download/${env:VULKAN_VERSION}/windows/vulkansdk-windows-X64-${env:VULKAN_VERSION}.exe"
|
|
& "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
|
|
Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
|
|
Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
|
|
|
|
- name: Activate MSVC environment
|
|
id: msvc_dev_cmd
|
|
uses: ilammy/msvc-dev-cmd@v1
|
|
|
|
- name: Build
|
|
id: cmake_build
|
|
run: |
|
|
mkdir build
|
|
cd build
|
|
cmake .. -DCMAKE_CXX_FLAGS='/bigobj' -G Ninja -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_BUILD_TYPE=Release ${{ matrix.defines }}
|
|
cmake --build .
|
|
|
|
- name: Check AVX512F support
|
|
id: check_avx512f
|
|
if: ${{ matrix.build == 'avx512' }}
|
|
continue-on-error: true
|
|
run: |
|
|
cd build
|
|
$vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
|
|
$msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
|
|
$cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe')
|
|
echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c
|
|
& $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main
|
|
.\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO"
|
|
|
|
- name: Get commit hash
|
|
id: commit
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
uses: pr-mpt/actions-commit-hash@v2
|
|
|
|
- name: Pack artifacts
|
|
id: pack_artifacts
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
run: |
|
|
$filePath = ".\build\bin\Release\*"
|
|
if (Test-Path $filePath) {
|
|
echo "Exists at path $filePath"
|
|
Copy-Item ggml/LICENSE .\build\bin\Release\ggml.txt
|
|
Copy-Item LICENSE .\build\bin\Release\stable-diffusion.cpp.txt
|
|
} elseif (Test-Path ".\build\bin\stable-diffusion.dll") {
|
|
$filePath = ".\build\bin\*"
|
|
echo "Exists at path $filePath"
|
|
Copy-Item ggml/LICENSE .\build\bin\ggml.txt
|
|
Copy-Item LICENSE .\build\bin\stable-diffusion.cpp.txt
|
|
} else {
|
|
ls .\build\bin
|
|
throw "Can't find stable-diffusion.dll"
|
|
}
|
|
7z a sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip $filePath
|
|
|
|
- name: Copy and pack Cuda runtime
|
|
id: pack_cuda_runtime
|
|
if: ${{ matrix.build == 'cuda12' && (github.event_name == 'push' && github.ref == 'refs/heads/master' || github.event.inputs.create_release == 'true') }}
|
|
run: |
|
|
echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
|
|
$dst='.\build\bin\cudart\'
|
|
robocopy "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
|
|
7z a cudart-sd-bin-win-cu12-x64.zip $dst\*
|
|
|
|
- name: Upload Cuda runtime
|
|
if: ${{ matrix.build == 'cuda12' && (github.event_name == 'push' && github.ref == 'refs/heads/master' || github.event.inputs.create_release == 'true') }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: sd-cudart-sd-bin-win-cu12-x64.zip
|
|
path: |
|
|
cudart-sd-bin-win-cu12-x64.zip
|
|
|
|
- name: Upload artifacts
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip
|
|
path: |
|
|
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip
|
|
|
|
windows-latest-cmake-hip:
|
|
runs-on: windows-2022
|
|
|
|
env:
|
|
HIPSDK_INSTALLER_VERSION: "25.Q3"
|
|
GPU_TARGETS: "gfx1151;gfx1200;gfx1201;gfx1100;gfx1101;gfx1102;gfx1030;gfx1031;gfx1032"
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Cache ROCm Installation
|
|
id: cache-rocm
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: C:\Program Files\AMD\ROCm
|
|
key: rocm-${{ env.HIPSDK_INSTALLER_VERSION }}-${{ runner.os }}
|
|
|
|
- name: ccache
|
|
uses: ggml-org/ccache-action@v1.2.16
|
|
with:
|
|
key: windows-latest-cmake-hip-${{ env.HIPSDK_INSTALLER_VERSION }}-x64
|
|
evict-old-files: 1d
|
|
|
|
- name: Install ROCm
|
|
if: steps.cache-rocm.outputs.cache-hit != 'true'
|
|
run: |
|
|
$ErrorActionPreference = "Stop"
|
|
write-host "Downloading AMD HIP SDK Installer"
|
|
Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-${{ env.HIPSDK_INSTALLER_VERSION }}-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
|
|
write-host "Installing AMD HIP SDK"
|
|
$proc = Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -PassThru
|
|
$completed = $proc.WaitForExit(600000)
|
|
if (-not $completed) {
|
|
Write-Error "ROCm installation timed out after 10 minutes. Killing the process"
|
|
$proc.Kill()
|
|
exit 1
|
|
}
|
|
if ($proc.ExitCode -ne 0) {
|
|
Write-Error "ROCm installation failed with exit code $($proc.ExitCode)"
|
|
exit 1
|
|
}
|
|
write-host "Completed AMD HIP SDK installation"
|
|
|
|
- name: Verify ROCm
|
|
run: |
|
|
# Find and test ROCm installation
|
|
$clangPath = Get-ChildItem 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | Select-Object -First 1
|
|
if (-not $clangPath) {
|
|
Write-Error "ROCm installation not found"
|
|
exit 1
|
|
}
|
|
& $clangPath.FullName --version
|
|
# Set HIP_PATH environment variable for later steps
|
|
echo "HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)" >> $env:GITHUB_ENV
|
|
|
|
- name: Build
|
|
run: |
|
|
mkdir build
|
|
cd build
|
|
$env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
|
|
cmake .. `
|
|
-G "Unix Makefiles" `
|
|
-DSD_HIPBLAS=ON `
|
|
-DSD_BUILD_SHARED_LIBS=ON `
|
|
-DGGML_NATIVE=OFF `
|
|
-DCMAKE_C_COMPILER=clang `
|
|
-DCMAKE_CXX_COMPILER=clang++ `
|
|
-DCMAKE_BUILD_TYPE=Release `
|
|
-DGPU_TARGETS="${{ env.GPU_TARGETS }}"
|
|
cmake --build . --config Release --parallel ${env:NUMBER_OF_PROCESSORS}
|
|
|
|
- name: Get commit hash
|
|
id: commit
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
uses: pr-mpt/actions-commit-hash@v2
|
|
|
|
- name: Pack artifacts
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
run: |
|
|
md "build\bin\rocblas\library\"
|
|
md "build\bin\hipblaslt\library"
|
|
cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
|
|
cp "${env:HIP_PATH}\bin\hipblaslt.dll" "build\bin\"
|
|
cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
|
|
cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
|
|
cp "${env:HIP_PATH}\bin\hipblaslt\library\*" "build\bin\hipblaslt\library\"
|
|
7z a sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip .\build\bin\*
|
|
|
|
- name: Upload artifacts
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip
|
|
path: |
|
|
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip
|
|
|
|
ubuntu-latest-rocm:
|
|
runs-on: ubuntu-latest
|
|
container: rocm/dev-ubuntu-24.04:7.2
|
|
|
|
env:
|
|
ROCM_VERSION: "7.2"
|
|
UBUNTU_VERSION: "24.04"
|
|
GPU_TARGETS: "gfx1151;gfx1150;gfx1100;gfx1101;gfx1102;gfx1200;gfx1201"
|
|
|
|
steps:
|
|
- run: apt-get update && apt-get install -y git
|
|
- name: Clone
|
|
id: checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Free disk space
|
|
run: |
|
|
# Remove preinstalled SDKs and caches not needed for this job
|
|
sudo rm -rf /usr/share/dotnet || true
|
|
sudo rm -rf /usr/local/lib/android || true
|
|
sudo rm -rf /opt/ghc || true
|
|
sudo rm -rf /usr/local/.ghcup || true
|
|
sudo rm -rf /opt/hostedtoolcache || true
|
|
|
|
# Remove old package lists and caches
|
|
sudo rm -rf /var/lib/apt/lists/* || true
|
|
sudo apt clean
|
|
|
|
- name: Dependencies
|
|
id: depends
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt install -y \
|
|
cmake \
|
|
hip-dev \
|
|
hipblas-dev \
|
|
ninja-build \
|
|
rocm-dev \
|
|
zip
|
|
# Clean apt caches to recover disk space
|
|
sudo apt clean
|
|
sudo rm -rf /var/lib/apt/lists/* || true
|
|
|
|
- name: Setup ROCm Environment
|
|
run: |
|
|
# Add ROCm to PATH for current session
|
|
echo "/opt/rocm/bin" >> $GITHUB_PATH
|
|
|
|
# Build regex pattern from ${{ env.GPU_TARGETS }} (match target as substring)
|
|
TARGET_REGEX="($(printf '%s' "${{ env.GPU_TARGETS }}" | sed 's/;/|/g'))"
|
|
|
|
# Remove library files for architectures we're not building for to save disk space
|
|
echo "Cleaning up unneeded architecture files..."
|
|
cd /opt/rocm/lib/rocblas/library
|
|
# Keep only our target architectures
|
|
for file in *; do
|
|
if printf '%s' "$file" | grep -q 'gfx'; then
|
|
if ! printf '%s' "$file" | grep -Eq "$TARGET_REGEX"; then
|
|
echo "Removing $file" &&
|
|
sudo rm -f "$file";
|
|
fi
|
|
fi
|
|
done
|
|
|
|
cd /opt/rocm/lib/hipblaslt/library
|
|
for file in *; do
|
|
if printf '%s' "$file" | grep -q 'gfx'; then
|
|
if ! printf '%s' "$file" | grep -Eq "$TARGET_REGEX"; then
|
|
echo "Removing $file" &&
|
|
sudo rm -f "$file";
|
|
fi
|
|
fi
|
|
done
|
|
|
|
- name: Build
|
|
id: cmake_build
|
|
run: |
|
|
mkdir build
|
|
cd build
|
|
cmake .. -G Ninja \
|
|
-DCMAKE_CXX_COMPILER=amdclang++ \
|
|
-DCMAKE_C_COMPILER=amdclang \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DSD_HIPBLAS=ON \
|
|
-DGPU_TARGETS="${{ env.GPU_TARGETS }}" \
|
|
-DAMDGPU_TARGETS="${{ env.GPU_TARGETS }}" \
|
|
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
|
|
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
|
|
-DSD_BUILD_SHARED_LIBS=ON
|
|
cmake --build . --config Release
|
|
|
|
- name: Get commit hash
|
|
id: commit
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
uses: pr-mpt/actions-commit-hash@v2
|
|
|
|
- name: Prepare artifacts
|
|
id: prepare_artifacts
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
run: |
|
|
# Copy licenses
|
|
cp ggml/LICENSE ./build/bin/ggml.txt
|
|
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
|
|
|
|
# Move ROCm runtime libraries (to avoid double space consumption)
|
|
sudo mv /opt/rocm/lib/librocsparse.so* ./build/bin/
|
|
sudo mv /opt/rocm/lib/libhsa-runtime64.so* ./build/bin/
|
|
sudo mv /opt/rocm/lib/libamdhip64.so* ./build/bin/
|
|
sudo mv /opt/rocm/lib/libhipblas.so* ./build/bin/
|
|
sudo mv /opt/rocm/lib/libhipblaslt.so* ./build/bin/
|
|
sudo mv /opt/rocm/lib/librocblas.so* ./build/bin/
|
|
sudo mv /opt/rocm/lib/rocblas/ ./build/bin/
|
|
sudo mv /opt/rocm/lib/hipblaslt/ ./build/bin/
|
|
|
|
- name: Fetch system info
|
|
id: system-info
|
|
run: |
|
|
echo "CPU_ARCH=`uname -m`" >> "$GITHUB_OUTPUT"
|
|
echo "OS_NAME=`lsb_release -s -i`" >> "$GITHUB_OUTPUT"
|
|
echo "OS_VERSION=`lsb_release -s -r`" >> "$GITHUB_OUTPUT"
|
|
echo "OS_TYPE=`uname -s`" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Pack artifacts
|
|
id: pack_artifacts
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
run: |
|
|
cp ggml/LICENSE ./build/bin/ggml.txt
|
|
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
|
|
zip -y -r sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-Ubuntu-${{ env.UBUNTU_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-rocm.zip ./build/bin
|
|
|
|
- name: Upload artifacts
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-Ubuntu-${{ env.UBUNTU_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-rocm.zip
|
|
path: |
|
|
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-Ubuntu-${{ env.UBUNTU_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-rocm.zip
|
|
|
|
release:
|
|
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
- ubuntu-latest-cmake
|
|
- ubuntu-latest-cmake-vulkan
|
|
- ubuntu-latest-rocm
|
|
- build-and-push-docker-images
|
|
- macOS-latest-cmake
|
|
- windows-latest-cmake
|
|
- windows-latest-cmake-hip
|
|
|
|
steps:
|
|
- name: Clone
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Download artifacts
|
|
id: download-artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: ./artifact
|
|
pattern: sd-*
|
|
merge-multiple: true
|
|
|
|
- name: Get commit count
|
|
id: commit_count
|
|
run: |
|
|
echo "count=$(git rev-list --count HEAD)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Get commit hash
|
|
id: commit
|
|
uses: pr-mpt/actions-commit-hash@v2
|
|
|
|
- name: Create release
|
|
id: create_release
|
|
if: ${{ github.event_name == 'workflow_dispatch' || github.ref_name == 'master' }}
|
|
uses: anzz1/action-create-release@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: ${{ format('{0}-{1}-{2}', env.BRANCH_NAME, steps.commit_count.outputs.count, steps.commit.outputs.short) }}
|
|
|
|
- name: Upload release
|
|
id: upload_release
|
|
if: ${{ github.event_name == 'workflow_dispatch' || github.ref_name == 'master' }}
|
|
uses: actions/github-script@v3
|
|
with:
|
|
github-token: ${{secrets.GITHUB_TOKEN}}
|
|
script: |
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
const release_id = '${{ steps.create_release.outputs.id }}';
|
|
for (let file of await fs.readdirSync('./artifact')) {
|
|
if (path.extname(file) === '.zip') {
|
|
console.log('uploadReleaseAsset', file);
|
|
await github.repos.uploadReleaseAsset({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
release_id: release_id,
|
|
name: file,
|
|
data: await fs.readFileSync(`./artifact/${file}`)
|
|
});
|
|
}
|
|
}
|