workflow: update build configurations for Linux and Windows CUDA

This commit is contained in:
jianlins 2026-03-11 21:44:36 -06:00
parent ab4c9081dc
commit 29b3c14619
3 changed files with 347 additions and 347 deletions

View File

@ -1,130 +1,130 @@
name: build-linux-cuda name: build-linux-cuda
on: on:
release: release:
types: [published] types: [published]
permissions: permissions:
contents: write contents: write
jobs: jobs:
build-linux-cuda: build-linux-cuda:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: nvidia/cuda:12.8.0-devel-rockylinux8 image: nvidia/cuda:12.8.0-devel-rockylinux8
env: env:
BUILD_TYPE: Release BUILD_TYPE: Release
ARCHIVE_BASENAME: llama-bin-linux-cuda-12.8-rockylinux8 ARCHIVE_BASENAME: llama-bin-linux-cuda-12.8-rockylinux8
steps: steps:
- name: Install build dependencies - name: Install build dependencies
shell: bash shell: bash
run: | run: |
set -euxo pipefail set -euxo pipefail
yum -y update yum -y update
yum -y install \ yum -y install \
git \ git \
cmake \ cmake \
gcc \ gcc \
gcc-c++ \ gcc-c++ \
make \ make \
ninja-build \ ninja-build \
tar \ tar \
gzip \ gzip \
zip \ zip \
findutils \ findutils \
file \ file \
which which
yum clean all yum clean all
- name: Checkout source at release tag - name: Checkout source at release tag
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
ref: ${{ github.event.release.tag_name }} ref: ${{ github.event.release.tag_name }}
submodules: recursive submodules: recursive
fetch-depth: 0 fetch-depth: 0
- name: Show build environment - name: Show build environment
shell: bash shell: bash
run: | run: |
set -euxo pipefail set -euxo pipefail
cat /etc/os-release || true cat /etc/os-release || true
uname -a uname -a
gcc --version gcc --version
g++ --version g++ --version
cmake --version cmake --version
nvcc --version nvcc --version
- name: Configure - name: Configure
shell: bash shell: bash
run: | run: |
set -euxo pipefail set -euxo pipefail
cmake -S . -B build \ cmake -S . -B build \
-G Ninja \ -G Ninja \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DGGML_CUDA=ON \ -DGGML_CUDA=ON \
-DCMAKE_CUDA_COMPILER=$(command -v nvcc) -DCMAKE_CUDA_COMPILER=$(command -v nvcc)
- name: Build - name: Build
shell: bash shell: bash
run: | run: |
set -euxo pipefail set -euxo pipefail
cmake --build build --config ${BUILD_TYPE} -j"$(nproc)" cmake --build build --config ${BUILD_TYPE} -j"$(nproc)"
- name: Prepare release payload - name: Prepare release payload
shell: bash shell: bash
run: | run: |
set -euxo pipefail set -euxo pipefail
TAG="${{ github.event.release.tag_name }}" TAG="${{ github.event.release.tag_name }}"
OUTDIR="${ARCHIVE_BASENAME}-${TAG}" OUTDIR="${ARCHIVE_BASENAME}-${TAG}"
mkdir -p "${OUTDIR}/bin" "${OUTDIR}/lib" "${OUTDIR}/meta" mkdir -p "${OUTDIR}/bin" "${OUTDIR}/lib" "${OUTDIR}/meta"
if [[ -d build/bin ]]; then if [[ -d build/bin ]]; then
find build/bin -maxdepth 1 -type f \( -name 'llama-*' -o -name 'ggml-*' \) -exec cp -av {} "${OUTDIR}/bin/" \; find build/bin -maxdepth 1 -type f \( -name 'llama-*' -o -name 'ggml-*' \) -exec cp -av {} "${OUTDIR}/bin/" \;
fi fi
find build -maxdepth 3 -type f \( -name 'libllama*' -o -name 'libggml*' \) -exec cp -av {} "${OUTDIR}/lib/" \; || true find build -maxdepth 3 -type f \( -name 'libllama*' -o -name 'libggml*' \) -exec cp -av {} "${OUTDIR}/lib/" \; || true
git rev-parse HEAD > "${OUTDIR}/meta/git-commit.txt" git rev-parse HEAD > "${OUTDIR}/meta/git-commit.txt"
git describe --tags --always > "${OUTDIR}/meta/git-describe.txt" || true git describe --tags --always > "${OUTDIR}/meta/git-describe.txt" || true
cat /etc/os-release > "${OUTDIR}/meta/os-release.txt" || true cat /etc/os-release > "${OUTDIR}/meta/os-release.txt" || true
gcc --version > "${OUTDIR}/meta/gcc-version.txt" gcc --version > "${OUTDIR}/meta/gcc-version.txt"
g++ --version > "${OUTDIR}/meta/gxx-version.txt" g++ --version > "${OUTDIR}/meta/gxx-version.txt"
cmake --version > "${OUTDIR}/meta/cmake-version.txt" cmake --version > "${OUTDIR}/meta/cmake-version.txt"
nvcc --version > "${OUTDIR}/meta/nvcc-version.txt" nvcc --version > "${OUTDIR}/meta/nvcc-version.txt"
if compgen -G "${OUTDIR}/bin/*" > /dev/null; then if compgen -G "${OUTDIR}/bin/*" > /dev/null; then
file "${OUTDIR}"/bin/* > "${OUTDIR}/meta/file-bin.txt" || true file "${OUTDIR}"/bin/* > "${OUTDIR}/meta/file-bin.txt" || true
ldd "${OUTDIR}"/bin/* > "${OUTDIR}/meta/ldd-bin.txt" || true ldd "${OUTDIR}"/bin/* > "${OUTDIR}/meta/ldd-bin.txt" || true
fi fi
if compgen -G "${OUTDIR}/lib/*" > /dev/null; then if compgen -G "${OUTDIR}/lib/*" > /dev/null; then
file "${OUTDIR}"/lib/* > "${OUTDIR}/meta/file-lib.txt" || true file "${OUTDIR}"/lib/* > "${OUTDIR}/meta/file-lib.txt" || true
ldd "${OUTDIR}"/lib/* > "${OUTDIR}/meta/ldd-lib.txt" || true ldd "${OUTDIR}"/lib/* > "${OUTDIR}/meta/ldd-lib.txt" || true
fi fi
tar -czf "${OUTDIR}.tar.gz" "${OUTDIR}" tar -czf "${OUTDIR}.tar.gz" "${OUTDIR}"
sha256sum "${OUTDIR}.tar.gz" > "${OUTDIR}.tar.gz.sha256" sha256sum "${OUTDIR}.tar.gz" > "${OUTDIR}.tar.gz.sha256"
- name: Upload tarball to release - name: Upload tarball to release
uses: actions/upload-release-asset@v1 uses: actions/upload-release-asset@v1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
upload_url: ${{ github.event.release.upload_url }} upload_url: ${{ github.event.release.upload_url }}
asset_path: ./llama-bin-linux-cuda-12.8-rockylinux8-${{ github.event.release.tag_name }}.tar.gz asset_path: ./llama-bin-linux-cuda-12.8-rockylinux8-${{ github.event.release.tag_name }}.tar.gz
asset_name: llama-bin-linux-cuda-12.8-rockylinux8-${{ github.event.release.tag_name }}.tar.gz asset_name: llama-bin-linux-cuda-12.8-rockylinux8-${{ github.event.release.tag_name }}.tar.gz
asset_content_type: application/gzip asset_content_type: application/gzip
- name: Upload checksum to release - name: Upload checksum to release
uses: actions/upload-release-asset@v1 uses: actions/upload-release-asset@v1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
upload_url: ${{ github.event.release.upload_url }} upload_url: ${{ github.event.release.upload_url }}
asset_path: ./llama-bin-linux-cuda-12.8-rockylinux8-${{ github.event.release.tag_name }}.tar.gz.sha256 asset_path: ./llama-bin-linux-cuda-12.8-rockylinux8-${{ github.event.release.tag_name }}.tar.gz.sha256
asset_name: llama-bin-linux-cuda-12.8-rockylinux8-${{ github.event.release.tag_name }}.tar.gz.sha256 asset_name: llama-bin-linux-cuda-12.8-rockylinux8-${{ github.event.release.tag_name }}.tar.gz.sha256
asset_content_type: text/plain asset_content_type: text/plain

View File

@ -1,177 +1,177 @@
name: custom_build_wincuda name: custom_build_wincuda
on: on:
workflow_dispatch: # allows manual triggering workflow_dispatch: # allows manual triggering
inputs: inputs:
create_release: create_release:
description: 'Create new release' description: 'Create new release'
required: true required: true
type: boolean type: boolean
cuda: cuda:
description: 'cuda version used to build. For available versions, check https://github.com/Jimver/cuda-toolkit/blob/master/src/links/windows-links.ts' description: 'cuda version used to build. For available versions, check https://github.com/Jimver/cuda-toolkit/blob/master/src/links/windows-links.ts'
required: false required: false
type: string type: string
default: '12.6.2' default: '12.6.2'
gpu_arch: gpu_arch:
description: 'nvidia gpu arch numbers' description: 'nvidia gpu arch numbers'
required: false required: false
type: string type: string
default: '70;75;80;86' default: '70;75;80;86'
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }} group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
cancel-in-progress: true cancel-in-progress: true
permissions: permissions:
contents: write contents: write
env: env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
GGML_NLOOP: 3 GGML_NLOOP: 3
GGML_N_THREADS: 1 GGML_N_THREADS: 1
LLAMA_LOG_COLORS: 1 LLAMA_LOG_COLORS: 1
LLAMA_LOG_PREFIX: 1 LLAMA_LOG_PREFIX: 1
LLAMA_LOG_TIMESTAMPS: 1 LLAMA_LOG_TIMESTAMPS: 1
jobs: jobs:
windows-latest-cmake-cuda: windows-latest-cmake-cuda:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- name: Clone - name: Clone
id: checkout id: checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Get Python - name: Get Python
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
python-version: 3.8.10 python-version: 3.8.10
- name: Install python dependencies - name: Install python dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install customtkinter==5.2.0 pyinstaller==5.11.0 psutil==5.9.5 pip install customtkinter==5.2.0 pyinstaller==5.11.0 psutil==5.9.5
- name: Download and install win64devkit - name: Download and install win64devkit
run: | run: |
curl -L https://github.com/skeeto/w64devkit/releases/download/v1.22.0/w64devkit-1.22.0.zip --output w64devkit.zip curl -L https://github.com/skeeto/w64devkit/releases/download/v1.22.0/w64devkit-1.22.0.zip --output w64devkit.zip
Expand-Archive w64devkit.zip -DestinationPath . Expand-Archive w64devkit.zip -DestinationPath .
- name: Add w64devkit to PATH - name: Add w64devkit to PATH
run: | run: |
echo "$(Get-Location)\w64devkit\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 echo "$(Get-Location)\w64devkit\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
- name: Print System Environment Variables - name: Print System Environment Variables
id: printvars id: printvars
run: | run: |
echo "Number of processors: ${env:NUMBER_OF_PROCESSORS}" echo "Number of processors: ${env:NUMBER_OF_PROCESSORS}"
echo "Processor Architecture: ${env:PROCESSOR_ARCHITECTURE}" echo "Processor Architecture: ${env:PROCESSOR_ARCHITECTURE}"
echo "Computer Name: ${env:COMPUTERNAME}" echo "Computer Name: ${env:COMPUTERNAME}"
wmic cpu get name wmic cpu get name
wmic os get TotalVisibleMemorySize, FreePhysicalMemory wmic os get TotalVisibleMemorySize, FreePhysicalMemory
- uses: Jimver/cuda-toolkit@v0.2.19 - uses: Jimver/cuda-toolkit@v0.2.19
id: cuda-toolkit id: cuda-toolkit
with: with:
cuda: ${{ github.event.inputs.cuda }} cuda: ${{ github.event.inputs.cuda }}
- name: Install ccache - name: Install ccache
uses: hendrikmuhs/ccache-action@v1.2 uses: hendrikmuhs/ccache-action@v1.2
with: with:
key: ${{ github.job }}-cuda${{ github.event.inputs.cuda }} key: ${{ github.job }}-cuda${{ github.event.inputs.cuda }}
- name: Build - name: Build
id: cmake_build id: cmake_build
run: | run: |
mkdir build mkdir build
cd build cd build
cmake .. -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES="${{ github.event.inputs.gpu_arch }}" -DCMAKE_SYSTEM_VERSION="10.0.19041.0" cmake .. -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES="${{ github.event.inputs.gpu_arch }}" -DCMAKE_SYSTEM_VERSION="10.0.19041.0"
cmake --build . --config Release -j 2 cmake --build . --config Release -j 2
- name: Determine tag name - name: Determine tag name
id: tag id: tag
shell: bash shell: bash
run: | run: |
BUILD_NUMBER="$(git rev-list --count HEAD)" BUILD_NUMBER="$(git rev-list --count HEAD)"
SHORT_HASH="$(git rev-parse --short=7 HEAD)" SHORT_HASH="$(git rev-parse --short=7 HEAD)"
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
echo "name=b${BUILD_NUMBER}-${{ github.event.inputs.cuda }}" >> $GITHUB_OUTPUT echo "name=b${BUILD_NUMBER}-${{ github.event.inputs.cuda }}" >> $GITHUB_OUTPUT
else else
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
echo "name=WinFull-${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}-${{ github.event.inputs.cuda }}" >> $GITHUB_OUTPUT echo "name=WinFull-${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}-${{ github.event.inputs.cuda }}" >> $GITHUB_OUTPUT
fi fi
- name: Pack artifacts - name: Pack artifacts
id: pack_artifacts id: pack_artifacts
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
run: | run: |
7z a llama-${{ steps.tag.outputs.name }}-bin-win-cu${{ github.event.inputs.cuda }}-x64.zip .\build\bin\Release\* 7z a llama-${{ steps.tag.outputs.name }}-bin-win-cu${{ github.event.inputs.cuda }}-x64.zip .\build\bin\Release\*
- name: Upload artifacts - name: Upload artifacts
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
path: llama-${{ steps.tag.outputs.name }}-bin-win-cu${{ github.event.inputs.cuda }}-x64.zip path: llama-${{ steps.tag.outputs.name }}-bin-win-cu${{ github.event.inputs.cuda }}-x64.zip
name: llama-bin-win-cu${{ github.event.inputs.cuda }}-x64.zip name: llama-bin-win-cu${{ github.event.inputs.cuda }}-x64.zip
- name: Copy and pack Cuda runtime - name: Copy and pack Cuda runtime
run: | run: |
echo "Cuda install location: ${{ env.CUDA_PATH }}" echo "Cuda install location: ${{ env.CUDA_PATH }}"
$dst='.\build\bin\cudart\' $dst='.\build\bin\cudart\'
robocopy "${{env.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll robocopy "${{env.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
robocopy "${{env.CUDA_PATH}}\lib" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll robocopy "${{env.CUDA_PATH}}\lib" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
7z a cudart-llama-bin-win-cu${{ github.event.inputs.cuda }}-x64.zip $dst\* 7z a cudart-llama-bin-win-cu${{ github.event.inputs.cuda }}-x64.zip $dst\*
- name: Upload Cuda runtime - name: Upload Cuda runtime
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
path: cudart-llama-bin-win-cu${{ github.event.inputs.cuda }}-x64.zip path: cudart-llama-bin-win-cu${{ github.event.inputs.cuda }}-x64.zip
name: cudart-llama-bin-win-cu${{ github.event.inputs.cuda }}-x64.zip name: cudart-llama-bin-win-cu${{ github.event.inputs.cuda }}-x64.zip
- name: Download artifacts - name: Download artifacts
id: download-artifact id: download-artifact
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
path: ./artifact path: ./artifact
- name: Move artifacts - name: Move artifacts
id: move_artifacts id: move_artifacts
run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
- name: Create release - name: Create release
id: create_release id: create_release
if: ${{ github.event.inputs.create_release == 'true' }} if: ${{ github.event.inputs.create_release == 'true' }}
uses: anzz1/action-create-release@v1 uses: anzz1/action-create-release@v1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
tag_name: ${{ steps.tag.outputs.name }} tag_name: ${{ steps.tag.outputs.name }}
- name: Upload release - name: Upload release
id: upload_release id: upload_release
if: ${{ github.event.inputs.create_release == 'true' }} if: ${{ github.event.inputs.create_release == 'true' }}
uses: actions/github-script@v3 uses: actions/github-script@v3
with: with:
github-token: ${{secrets.GITHUB_TOKEN}} github-token: ${{secrets.GITHUB_TOKEN}}
script: | script: |
const path = require('path'); const path = require('path');
const fs = require('fs'); const fs = require('fs');
const release_id = '${{ steps.create_release.outputs.id }}'; const release_id = '${{ steps.create_release.outputs.id }}';
for (let file of await fs.readdirSync('./artifact/release')) { for (let file of await fs.readdirSync('./artifact/release')) {
if (path.extname(file) === '.zip') { if (path.extname(file) === '.zip') {
console.log('uploadReleaseAsset', file); console.log('uploadReleaseAsset', file);
await github.repos.uploadReleaseAsset({ await github.repos.uploadReleaseAsset({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
release_id: release_id, release_id: release_id,
name: file, name: file,
data: await fs.readFileSync(`./artifact/release/${file}`) data: await fs.readFileSync(`./artifact/release/${file}`)
}); });
} }
} }

View File

@ -1,40 +1,40 @@
name: Sync Upstream name: Sync Upstream
on: on:
schedule: schedule:
- cron: '0 0 * * 0' # Every Sunday at midnight - cron: '0 0 * * 0' # Every Sunday at midnight
jobs: jobs:
merge: merge:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout master branch - name: Checkout master branch
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
ref: master ref: master
- name: Merge upstream master - name: Merge upstream master
id: merge id: merge
run: | run: |
git remote add upstream https://github.com/ggml-org/repository.git git remote add upstream https://github.com/ggml-org/repository.git
git fetch upstream git fetch upstream
if git merge upstream/master; then if git merge upstream/master; then
echo "merge_success=true" >> $GITHUB_OUTPUT echo "merge_success=true" >> $GITHUB_OUTPUT
else else
echo "merge_success=false" >> $GITHUB_OUTPUT echo "merge_success=false" >> $GITHUB_OUTPUT
echo "Automatic merge failed. Skipping push." echo "Automatic merge failed. Skipping push."
exit 0 exit 0
fi fi
- name: Push changes - name: Push changes
if: steps.merge.outputs.merge_success == 'true' if: steps.merge.outputs.merge_success == 'true'
run: | run: |
# Check if there are any changes # Check if there are any changes
if git diff --quiet HEAD@{1} HEAD; then if git diff --quiet HEAD@{1} HEAD; then
echo "No changes to push" echo "No changes to push"
else else
echo "Changes detected, pushing updates..." echo "Changes detected, pushing updates..."
git push origin master git push origin master
fi fi
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}