Compare commits

..

No commits in common. "e0aa7c4bda17ca12e7584d3a09a0bb0039740adb" and "9fd65e14ae09dca5d8f5c965ef525e95143e9f31" have entirely different histories.

3 changed files with 72 additions and 194 deletions

View File

@ -31,7 +31,7 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
id: checkout id: checkout
uses: actions/checkout@v6 uses: actions/checkout@v4.2.2
with: with:
repository: 'leejet/stable-diffusion.cpp' repository: 'leejet/stable-diffusion.cpp'
ref: '${{ github.event.inputs.commit }}' ref: '${{ github.event.inputs.commit }}'
@ -58,19 +58,41 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
id: checkout id: checkout
uses: actions/checkout@v6 uses: actions/checkout@v4.2.2
with: with:
repository: 'leejet/stable-diffusion.cpp' repository: 'leejet/stable-diffusion.cpp'
ref: '${{ github.event.inputs.commit }}' ref: '${{ github.event.inputs.commit }}'
submodules: recursive submodules: recursive
- name: Install cuda-toolkit - name: Install Cuda Toolkit 12.8
id: cuda-toolkit id: cuda-12
uses: Jimver/cuda-toolkit@v0.2.22 run: |
with: mkdir -p "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8"
cuda: "12.8.1" choco install unzip -y
method: "network" curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cudart/windows-x86_64/cuda_cudart-windows-x86_64-12.8.57-archive.zip"
sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]' curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvcc/windows-x86_64/cuda_nvcc-windows-x86_64-12.8.61-archive.zip"
curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvrtc/windows-x86_64/cuda_nvrtc-windows-x86_64-12.8.61-archive.zip"
curl -O "https://developer.download.nvidia.com/compute/cuda/redist/libcublas/windows-x86_64/libcublas-windows-x86_64-12.8.3.14-archive.zip"
curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvtx/windows-x86_64/cuda_nvtx-windows-x86_64-12.8.55-archive.zip"
curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_profiler_api/windows-x86_64/cuda_profiler_api-windows-x86_64-12.8.55-archive.zip"
curl -O "https://developer.download.nvidia.com/compute/cuda/redist/visual_studio_integration/windows-x86_64/visual_studio_integration-windows-x86_64-12.8.55-archive.zip"
curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvprof/windows-x86_64/cuda_nvprof-windows-x86_64-12.8.57-archive.zip"
curl -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cccl/windows-x86_64/cuda_cccl-windows-x86_64-12.8.55-archive.zip"
unzip '*.zip' -d "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8"
xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\cuda_cudart-windows-x86_64-12.8.57-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y
xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\cuda_nvcc-windows-x86_64-12.8.61-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y
xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\cuda_nvrtc-windows-x86_64-12.8.61-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y
xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\libcublas-windows-x86_64-12.8.3.14-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y
xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\cuda_nvtx-windows-x86_64-12.8.55-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y
xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\cuda_profiler_api-windows-x86_64-12.8.55-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y
xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\visual_studio_integration-windows-x86_64-12.8.55-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y
xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\cuda_nvprof-windows-x86_64-12.8.57-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y
xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\cuda_cccl-windows-x86_64-12.8.55-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y
xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\visual_studio_integration\MSBuildExtensions\*" "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\BuildCustomizations" /E /I /H /Y
echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\libnvvp" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
echo "CUDA_PATH_V12_8=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
- name: Build - name: Build
id: cmake_build id: cmake_build
@ -79,7 +101,7 @@ jobs:
mkdir build mkdir build
cd build cd build
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
cmake .. -DSD_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES="61;70;75;80;86;89;90;100;120" -DSD_BUILD_SHARED_LIBS=ON cmake .. -DSD_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES="61;75;86;89;100" -DSD_BUILD_SHARED_LIBS=ON
cmake --build . --config Release cmake --build . --config Release
- name: Upload artifact - name: Upload artifact
@ -92,53 +114,18 @@ jobs:
windows-hip: windows-hip:
runs-on: windows-latest runs-on: windows-latest
env: steps:
HIPSDK_INSTALLER_VERSION: "25.Q3" - name: Install
GPU_TARGETS: "gfx1151;gfx1200;gfx1201;gfx1100;gfx1101;gfx1102;gfx1030;gfx1031;gfx1032" id: depends
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v6
with:
repository: 'leejet/stable-diffusion.cpp'
ref: '${{ github.event.inputs.commit }}'
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: | run: |
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
write-host "Downloading AMD HIP SDK Installer" 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" Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-25.Q3-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
write-host "Installing AMD HIP SDK" write-host "Installing AMD HIP SDK"
$proc = Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -PassThru Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
$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" write-host "Completed AMD HIP SDK installation"
- name: Verify ROCm - name: Verify ROCm
id: verify
run: | run: |
# Find and test ROCm installation # Find and test ROCm installation
$clangPath = Get-ChildItem 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | Select-Object -First 1 $clangPath = Get-ChildItem 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | Select-Object -First 1
@ -147,24 +134,24 @@ jobs:
exit 1 exit 1
} }
& $clangPath.FullName --version & $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: Checkout
id: checkout
uses: actions/checkout@v4.2.2
with:
repository: 'leejet/stable-diffusion.cpp'
ref: '${{ github.event.inputs.commit }}'
submodules: recursive
- name: Build - name: Build
id: cmake_build
run: | run: |
$env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
$env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
mkdir build mkdir build
cd build cd build
$env:CMAKE_PREFIX_PATH="${env:HIP_PATH}" cmake -G "Unix Makefiles" .. -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" -DGGML_HIP=ON -DCMAKE_BUILD_TYPE=Release -DAMDGPU_TARGETS="gfx1100;gfx1101;gfx1030" -DGGML_RPC=ON -DSD_BUILD_SHARED_LIBS=ON
cmake .. ` cmake --build . --config Release
-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: Upload artifact - name: Upload artifact
id: upload_artifact id: upload_artifact
@ -182,7 +169,7 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
id: checkout id: checkout
uses: actions/checkout@v6 uses: actions/checkout@v4.2.2
with: with:
repository: 'leejet/stable-diffusion.cpp' repository: 'leejet/stable-diffusion.cpp'
ref: '${{ github.event.inputs.commit }}' ref: '${{ github.event.inputs.commit }}'
@ -229,18 +216,12 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
id: checkout id: checkout
uses: actions/checkout@v6 uses: actions/checkout@v4.2.2
with: with:
repository: 'leejet/stable-diffusion.cpp' repository: 'leejet/stable-diffusion.cpp'
ref: '${{ github.event.inputs.commit }}' ref: '${{ github.event.inputs.commit }}'
submodules: recursive submodules: recursive
- name: Dependencies
id: depends
run: |
sudo apt-get update
sudo apt-get install build-essential
- name: Build - name: Build
id: cmake_build id: cmake_build
run: | run: |
@ -256,39 +237,6 @@ jobs:
name: linux-${{ matrix.build }} name: linux-${{ matrix.build }}
path: ./build/bin/libstable-diffusion.so path: ./build/bin/libstable-diffusion.so
linux-vulkan:
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v6
with:
repository: 'leejet/stable-diffusion.cpp'
ref: '${{ github.event.inputs.commit }}'
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: Upload artifact
id: upload_artifact
uses: actions/upload-artifact@v4.6.1
with:
name: linux-vulkan
path: ./build/bin/libstable-diffusion.so
linux-cuda12: linux-cuda12:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: nvidia/cuda:12.8.0-devel-ubuntu24.04 container: nvidia/cuda:12.8.0-devel-ubuntu24.04
@ -303,7 +251,7 @@ jobs:
- name: Checkout - name: Checkout
id: checkout id: checkout
uses: actions/checkout@v6 uses: actions/checkout@v4.2.2
with: with:
repository: 'leejet/stable-diffusion.cpp' repository: 'leejet/stable-diffusion.cpp'
ref: '${{ github.event.inputs.commit }}' ref: '${{ github.event.inputs.commit }}'
@ -330,7 +278,7 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
id: checkout id: checkout
uses: actions/checkout@v6 uses: actions/checkout@v4.2.2
with: with:
repository: 'leejet/stable-diffusion.cpp' repository: 'leejet/stable-diffusion.cpp'
ref: '${{ github.event.inputs.commit }}' ref: '${{ github.event.inputs.commit }}'
@ -365,99 +313,31 @@ jobs:
path: ./build/bin/libstable-diffusion.so path: ./build/bin/libstable-diffusion.so
linux-hip: linux-hip:
runs-on: ubuntu-latest runs-on: ubuntu-22.04
container: rocm/dev-ubuntu-24.04:7.2 container: rocm/dev-ubuntu-22.04:6.4.4
env:
ROCM_VERSION: "7.2"
UBUNTU_VERSION: "24.04"
GPU_TARGETS: "gfx1151;gfx1150;gfx1100;gfx1101;gfx1102;gfx1200;gfx1201"
steps: steps:
- run: apt-get update && apt-get install -y git
- name: Checkout
id: checkout
uses: actions/checkout@v6
with:
repository: 'leejet/stable-diffusion.cpp'
ref: '${{ github.event.inputs.commit }}'
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 - name: Dependencies
id: depends id: depends
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt install -y \ sudo apt-get install -y build-essential git cmake rocblas-dev hipblas-dev
cmake \ hipconfig
hip-dev \
hipblas-dev \ - name: Clone
ninja-build \ id: checkout
rocm-dev \ uses: actions/checkout@v4.2.2
zip with:
# Clean apt caches to recover disk space repository: 'leejet/stable-diffusion.cpp'
sudo apt clean ref: '${{ github.event.inputs.commit }}'
sudo rm -rf /var/lib/apt/lists/* || true submodules: recursive
- 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 - name: Build
id: cmake_build id: cmake_build
run: | run: |
mkdir build mkdir build
cd build cd build
cmake .. -G Ninja \ cmake .. -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" -DGGML_HIP=ON -DSD_BUILD_SHARED_LIBS=ON
-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 cmake --build . --config Release
- name: Upload artifact Rocm - name: Upload artifact Rocm
@ -485,7 +365,7 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
id: checkout id: checkout
uses: actions/checkout@v6 uses: actions/checkout@v4.2.2
with: with:
repository: 'leejet/stable-diffusion.cpp' repository: 'leejet/stable-diffusion.cpp'
ref: '${{ github.event.inputs.commit }}' ref: '${{ github.event.inputs.commit }}'
@ -516,7 +396,6 @@ jobs:
- windows-hip - windows-hip
- windows-vulkan - windows-vulkan
- linux-cpu - linux-cpu
- linux-vulkan
- linux-cuda12 - linux-cuda12
- linux-sycl - linux-sycl
- linux-hip - linux-hip
@ -525,7 +404,7 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
id: checkout id: checkout
uses: actions/checkout@v6 uses: actions/checkout@v4.2.2
- name: Download artifacts - name: Download artifacts
id: download_artifacts id: download_artifacts

View File

@ -19,7 +19,6 @@
<file src="StableDiffusion.NET.Backend.props" target="build/net8.0/StableDiffusion.NET.Backend.Vulkan.props" /> <file src="StableDiffusion.NET.Backend.props" target="build/net8.0/StableDiffusion.NET.Backend.Vulkan.props" />
<file src="windows-vulkan/stable-diffusion.dll" target="runtimes\win-x64\native\vulkan\stable-diffusion.dll" /> <file src="windows-vulkan/stable-diffusion.dll" target="runtimes\win-x64\native\vulkan\stable-diffusion.dll" />
<file src="linux-vulkan/libstable-diffusion.so" target="runtimes\linux-x64\native\vulkan\libstable-diffusion.so" />
<file src="sd_net_vulkan.png" target="sd_net_vulkan.png" /> <file src="sd_net_vulkan.png" target="sd_net_vulkan.png" />
<file src="readme.md" target="readme.md" /> <file src="readme.md" target="readme.md" />

View File

@ -13,7 +13,7 @@ public class VulkanBackend : IBackend
public int Priority { get; set; } = 5; public int Priority { get; set; } = 5;
public bool IsAvailable => (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) public bool IsAvailable => RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
&& (RuntimeInformation.OSArchitecture == Architecture.X64); && (RuntimeInformation.OSArchitecture == Architecture.X64);
public string PathPart => "vulkan"; public string PathPart => "vulkan";