diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4112ae9bb..dbd1b36e9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,12 +1,15 @@ -name: CI +name: CI # Mantém o nome do workflow on: - workflow_dispatch: # allows manual triggering + workflow_dispatch: # permite acionamento manual inputs: create_release: description: "Create new release" required: true type: boolean + # Mantive os triggers push e pull_request. + # Se você quiser que o workflow execute SÓ quando você acionar manualmente, + # pode comentar as seções 'push:' e 'pull_request:'. push: branches: - master @@ -39,135 +42,24 @@ env: BRANCH_NAME: ${{ github.head_ref || github.ref_name }} jobs: - ubuntu-latest-cmake: - runs-on: ubuntu-latest + # Omitindo o job 'ubuntu-latest-cmake' aqui para focar apenas no Windows/CUDA + # ubuntu-latest-cmake: + # ... (conteúdo do job ubuntu-latest-cmake) ... - 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/main' ) || 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 - - 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/main' ) || 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 + # Omitindo o job 'macOS-latest-cmake' aqui para focar apenas no Windows/CUDA + # macOS-latest-cmake: + # ... (conteúdo do job macOS-latest-cmake) ... windows-latest-cmake: - runs-on: windows-2025 - - env: - VULKAN_VERSION: 1.3.261.1 + runs-on: windows-2025 # Mantendo o runner que você já tinha 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" + # Deixa APENAS a configuração CUDA 12 - build: "cuda12" - defines: "-DSD_CUDA=ON -DSD_BUILD_SHARED_LIBS=ON -DCMAKE_CUDA_ARCHITECTURES=90;89;80;75" - # - build: "rocm5.5" - # defines: '-G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSD_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DAMDGPU_TARGETS="gfx1100;gfx1102;gfx1030" -DSD_BUILD_SHARED_LIBS=ON' - - build: 'vulkan' - defines: "-DSD_VULKAN=ON -DSD_BUILD_SHARED_LIBS=ON" + # Altera a arquitetura para APENAS 75 + defines: "-DSD_CUDA=ON -DSD_BUILD_SHARED_LIBS=ON -DCMAKE_CUDA_ARCHITECTURES=75" steps: - name: Clone id: checkout @@ -177,6 +69,7 @@ jobs: - name: Install cuda-toolkit id: cuda-toolkit + # Esta condição permanecerá verdadeira, pois agora só há a matrix 'cuda12' if: ${{ matrix.build == 'cuda12' }} uses: Jimver/cuda-toolkit@v0.2.19 with: @@ -184,57 +77,54 @@ jobs: method: "network" sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]' - - name: Install rocm-toolkit - id: rocm-toolkit - if: ${{ matrix.build == 'rocm5.5' }} - uses: Cyberhan123/rocm-toolkit@v0.1.0 - with: - rocm: "5.5.0" - - - name: Install Ninja - id: install-ninja - if: ${{ matrix.build == 'rocm5.5' }} - uses: urkle/action-get-ninja@v1 - with: - version: 1.11.1 - - 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/$%7Benv:VULKAN_VERSION%7D/windows/VulkanSDK-$%7Benv:VULKAN_VERSION%7D-Installer.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" + # Removendo/Comentando os passos de instalação/configuração de outras ferramentas + # que não são usadas no build CUDA específico. + # Exemplo: + # - name: Install rocm-toolkit + # id: rocm-toolkit + # if: ${{ matrix.build == 'rocm5.5' }} + # uses: Cyberhan123/rocm-toolkit@v0.1.0 + # with: + # rocm: "5.5.0" + # - name: Install Ninja + # id: install-ninja + # if: ${{ matrix.build == 'rocm5.5' }} + # uses: urkle/action-get-ninja@v1 + # with: + # version: 1.11.1 + # - name: Install Vulkan SDK + # id: get_vulkan + # if: ${{ matrix.build == 'vulkan' }} + # run: | + # ... - name: Build id: cmake_build run: | mkdir build cd build + # Usa as 'defines' atualizadas da sua matrix (só CUDA 75) cmake .. ${{ matrix.defines }} cmake --build . --config Release - - 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" + # Removendo/Comentando o passo de Check AVX512F support se não for necessário para este build + # - name: Check AVX512F support + # id: check_avx512f + # if: ${{ matrix.build == 'avx512' }} + # continue-on-error: true + # run: | + # ... - name: Get commit hash id: commit - if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} + # Simplifiquei a condição para sempre rodar se acionado manualmente ou em push para main/master + if: ${{ github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }} 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' }} + # Simplifiquei a condição para sempre rodar + if: ${{ github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }} run: | $filePath = ".\build\bin\Release\*" if (Test-Path $filePath) { @@ -254,7 +144,8 @@ jobs: - name: Copy and pack Cuda runtime id: pack_cuda_runtime - if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.build == 'cuda12' ) || github.event.inputs.create_release == 'true' }} + # Esta condição agora será sempre verdadeira, já que é o único build na matriz + if: ${{ matrix.build == 'cuda12' }} run: | echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}" $dst='.\build\bin\cudart\' @@ -262,7 +153,8 @@ jobs: 7z a cudart-sd-bin-win-cu12-x64.zip $dst\* - name: Upload Cuda runtime - if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.build == 'cuda12' ) || github.event.inputs.create_release == 'true' }} + # Esta condição agora será sempre verdadeira + if: ${{ matrix.build == 'cuda12' }} uses: actions/upload-artifact@v4 with: name: sd-cudart-sd-bin-win-cu12-x64.zip @@ -270,62 +162,21 @@ jobs: 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' }} + # Simplifiquei a condição para sempre rodar + if: ${{ github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }} 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 - 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 - - macOS-latest-cmake - - windows-latest-cmake - - steps: - - name: Download artifacts - id: download-artifact - uses: actions/download-artifact@v4 - with: - path: ./artifact - pattern: sd-* - merge-multiple: true - - - name: Get commit hash - id: commit - uses: pr-mpt/actions-commit-hash@v2 - - - name: Create release - id: create_release - uses: anzz1/action-create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }} - - - name: Upload release - id: upload_release - 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}`) - }); - } - } + # Omitindo o job 'release' para este cenário de build focado. + # Se você precisar do job 'release' no futuro, ele precisará ser reconfigurado + # para depender apenas deste job 'windows-latest-cmake' ou do artefato específico do CUDA. + # release: + # if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} + # runs-on: ubuntu-latest + # needs: + # - windows-latest-cmake # Ajuste aqui para depender só do Windows + # steps: + # ... (conteúdo do job release) ...