From 0b08e1c394f8e2709bb0da3fb8f7c3d02d4a7152 Mon Sep 17 00:00:00 2001 From: vuonghoainam Date: Sun, 8 Oct 2023 19:50:47 +0700 Subject: [PATCH] fix(ci-windows): Use 1 value in windows matrix, package nitro windows GPU dll --- .github/workflows/build.yml | 185 +++++++++--------------------------- 1 file changed, 44 insertions(+), 141 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 000c41e95..6a3bdfb0b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -226,11 +226,13 @@ jobs: # with: # repo_token: ${{ secrets.GITHUB_TOKEN }} # file: nitro.zip - # asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-mac-amd64.zip.zip + # asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-mac-amd64.zip # tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} windows-amd64-build: runs-on: windows-latest + permissions: + contents: write env: OPENBLAS_VERSION: 0.3.23 @@ -240,39 +242,17 @@ jobs: strategy: matrix: include: - - build: 'avx512' - defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX512=ON -DBUILD_SHARED_LIBS=ON' - build: 'openblas' defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_BLAS=ON -DBUILD_SHARED_LIBS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"' steps: - name: Clone + id: checkout uses: actions/checkout@v3 with: submodules: recursive - - name: Download OpenCL SDK - id: get_opencl - if: ${{ matrix.build == 'clblast' }} - run: | - curl.exe -o $env:RUNNER_TEMP/opencl.zip -L "https://github.com/KhronosGroup/OpenCL-SDK/releases/download/v${env:OPENCL_VERSION}/OpenCL-SDK-v${env:OPENCL_VERSION}-Win-x64.zip" - mkdir $env:RUNNER_TEMP/opencl - tar.exe -xvf $env:RUNNER_TEMP/opencl.zip --strip-components=1 -C $env:RUNNER_TEMP/opencl - - - name: Download CLBlast - id: get_clblast - if: ${{ matrix.build == 'clblast' }} - run: | - curl.exe -o $env:RUNNER_TEMP/clblast.7z -L "https://github.com/CNugteren/CLBlast/releases/download/${env:CLBLAST_VERSION}/CLBlast-${env:CLBLAST_VERSION}-windows-x64.7z" - curl.exe -o $env:RUNNER_TEMP/CLBlast.LICENSE.txt -L "https://github.com/CNugteren/CLBlast/raw/${env:CLBLAST_VERSION}/LICENSE" - 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/clblast.7z - rename-item $env:RUNNER_TEMP/CLBlast-${env:CLBLAST_VERSION}-windows-x64 clblast - foreach ($f in (gci -Recurse -Path "$env:RUNNER_TEMP/clblast" -Filter '*.cmake')) { - $txt = Get-Content -Path $f -Raw - $txt.Replace('C:/vcpkg/packages/opencl_x64-windows/', "$($env:RUNNER_TEMP.Replace('\','/'))/opencl/") | Set-Content -Path $f -Encoding UTF8 - } - - name: Download OpenBLAS id: get_openblas if: ${{ matrix.build == 'openblas' }} @@ -296,51 +276,46 @@ jobs: cmake .. ${{ matrix.defines }} cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS} - - name: Add clblast.dll - id: add_clblast_dll - if: ${{ matrix.build == 'clblast' }} - run: | - cp $env:RUNNER_TEMP/clblast/lib/clblast.dll ./build/bin/Release - cp $env:RUNNER_TEMP/CLBlast.LICENSE.txt ./build/bin/Release/CLBlast-${env:CLBLAST_VERSION}.txt - - name: Add libopenblas.dll id: add_libopenblas_dll if: ${{ matrix.build == 'openblas' }} run: | - cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll - cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt + cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/Release/openblas.dll + cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt - - name: Determine tag name - id: tag + - name: Extract branch name shell: bash - run: | - BUILD_NUMBER="$(git rev-list --count HEAD)" - SHORT_HASH="$(git rev-parse --short=7 HEAD)" - if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then - echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT - else - SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') - echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT - fi + id: extract_branch + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + + - name: Extract commit short SHA + id: extract_commit_id + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - name: Pack artifacts id: pack_artifacts # if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} run: | - Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt + $dst='.\build\Release' robocopy build_deps\_install\bin\zlib.dll $dst robocopy build\bin\Release\llama.dll $dst - 7z a nitro-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-x64.zip .\build\bin\Release\* + mkdir -p .\build\Release\config + robocopy config.json .\build\Release\config + 7z a nitro.zip .\build\Release\* - - name: Upload artifacts + - name: Upload binaries to release # if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} - uses: actions/upload-artifact@v3 + uses: svenstaro/upload-release-action@v2 with: - path: | - nitro-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-x64.zip + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: nitro.zip + asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-win-amd64-${{ matrix.build }}.zip + tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} windows-amd64-cuda-build: runs-on: windows-nvidia + permissions: + contents: write strategy: matrix: @@ -371,105 +346,33 @@ jobs: cmake .. -DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_CUBLAS=ON -DBUILD_SHARED_LIBS=ON cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS} - - name: Determine tag name - id: tag + - name: Extract branch name shell: bash - run: | - BUILD_NUMBER="$(git rev-list --count HEAD)" - SHORT_HASH="$(git rev-parse --short=7 HEAD)" - if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then - echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT - else - SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') - echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT - fi + id: extract_branch + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + + - name: Extract commit short SHA + id: extract_commit_id + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + - name: Pack artifacts id: pack_artifacts if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} run: | - 7z a nitro-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\* - - - name: Upload artifacts - # if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} - uses: actions/upload-artifact@v3 - with: - path: | - nitro-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip - - - name: Copy and pack Cuda runtime - 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 + $dst='.\build\Release' robocopy build_deps\_install\bin\zlib.dll $dst robocopy build\bin\Release\llama.dll $dst - 7z a cudart-nitro-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\* + robocopy "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll + mkdir -p .\build\Release\config + robocopy config.json .\build\Release\config + 7z a nitro.zip .\build\Release\* - - name: Upload Cuda runtime + - name: Upload binaries to release # if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} - uses: actions/upload-artifact@v3 - with: - path: | - cudart-nitro-bin-win-cu${{ matrix.cuda }}-x64.zip - - release: - runs-on: ubuntu-latest - - needs: - - windows-amd64-build - - windows-amd64-cuda-build - - steps: - - name: Clone - id: checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Determine tag name - id: tag - shell: bash - run: | - BUILD_NUMBER="$(git rev-list --count HEAD)" - SHORT_HASH="$(git rev-parse --short=7 HEAD)" - if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then - echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT - else - SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') - echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT - fi - - - name: Download artifacts - id: download-artifact - uses: actions/download-artifact@v3 - - - name: Create release - id: create_release - uses: anzz1/action-create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.tag.outputs.name }} - - - name: Upload release - id: upload_release - uses: actions/github-script@v3 + uses: svenstaro/upload-release-action@v2 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}`) - }); - } - } \ No newline at end of file + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: nitro.zip + asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-win-amd64-${{ matrix.build }}-cu${{ matrix.cuda }}.zip + tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }}