Merge pull request #29 from apicalshark/1 #40
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: JUSTBUILD | |
on: | |
workflow_dispatch: # allows manual triggering | |
inputs: | |
create_release: | |
description: "Create new release" | |
required: true | |
type: boolean | |
push: | |
branches: | |
- master | |
paths: | |
[ | |
".github/workflows/build-ci.yml", | |
"**/CMakeLists.txt", | |
"**/Makefile", | |
"**/*.h", | |
"**/*.hpp", | |
"**/*.c", | |
"**/*.cpp", | |
"**/*.cu", | |
"**/*.cuh", | |
"**/*.swift", | |
"**/*.m", | |
"**/*.metal", | |
] | |
pull_request: | |
types: [opened, synchronize, reopened] | |
paths: | |
[ | |
".github/workflows/build-ci.yml", | |
"**/CMakeLists.txt", | |
"**/Makefile", | |
"**/*.h", | |
"**/*.hpp", | |
"**/*.c", | |
"**/*.cpp", | |
"**/*.cu", | |
"**/*.cuh", | |
"**/*.swift", | |
"**/*.m", | |
"**/*.metal", | |
] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }} | |
cancel-in-progress: true | |
# Fine-grant permission | |
# https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token | |
#permissions: | |
# contents: write # for creating release | |
permissions: write-all | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
#GGML_NLOOP: 3 | |
#GGML_N_THREADS: 1 | |
#LLAMA_LOG_COLORS: 1 | |
#LLAMA_LOG_PREFIX: 1 | |
#LLAMA_LOG_TIMESTAMPS: 1 | |
jobs: | |
# CUDA Release | |
ubuntu-latest-cuda-cmake: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Free Disk Space (Ubuntu) | |
uses: jlumbroso/free-disk-space@main | |
with: | |
# this might remove tools that are actually needed, | |
# if set to "true" but frees about 6 GB | |
tool-cache: true | |
# all of these default to true, but feel free to set to | |
# "false" if necessary for your workflow | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: true | |
docker-images: true | |
swap-storage: true | |
- name: Clone | |
id: checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Dependencies | |
id: depends | |
run: | | |
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb | |
sudo dpkg -i cuda-keyring_1.1-1_all.deb | |
sudo apt-get update | |
sudo apt-get install build-essential libcurl4-openssl-dev ccache cuda-toolkit-12-6 | |
sudo apt install software-properties-common | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
sudo apt update | |
sudo apt install gcc-12 g++-12 | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12 --slave /usr/bin/g++ g++ /usr/bin/g++-12 | |
- name: Build | |
id: cmake_build | |
run: | | |
export PATH=/usr/local/cuda-12.6/bin${PATH:+:${PATH}} | |
export LD_LIBRARY_PATH=/usr/local/cuda-12.6/lib64 ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} | |
mkdir build | |
cd build | |
cmake .. -DLLAMA_FATAL_WARNINGS=OFF -DBUILD_SHARED_LIBS=ON -DGGML_CUDA=ON | |
cmake --build . --config Release -j $(nproc) | |
- 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: Pack artifacts | |
id: pack_artifacts | |
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} | |
run: | | |
cp LICENSE ./build/bin/ | |
cp $(find . -name "*.so") ./build/bin/ | |
zip -r cudart-llama-${{ steps.tag.outputs.name }}-bin-ubuntu-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: | |
path: cudart-llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.zip | |
name: cudart-llama-bin-ubuntu-x64.zip | |
# Vulkan Release | |
ubuntu-latest-vulkan-cmake: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Free Disk Space (Ubuntu) | |
uses: jlumbroso/free-disk-space@main | |
with: | |
# this might remove tools that are actually needed, | |
# if set to "true" but frees about 6 GB | |
tool-cache: true | |
# all of these default to true, but feel free to set to | |
# "false" if necessary for your workflow | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: true | |
docker-images: true | |
swap-storage: true | |
- name: Clone | |
id: checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Dependencies | |
id: depends | |
run: | | |
wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add - | |
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list | |
sudo apt-get update | |
sudo apt-get install build-essential libcurl4-openssl-dev vulkan-sdk ccache | |
sudo apt install software-properties-common | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
sudo apt update | |
sudo apt install gcc-13 g++-13 | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 13 --slave /usr/bin/g++ g++ /usr/bin/g++-13 | |
- name: Build | |
id: cmake_build | |
run: | | |
mkdir build | |
cd build | |
cmake .. -DLLAMA_FATAL_WARNINGS=OFF -DBUILD_SHARED_LIBS=ON -DGGML_VULKAN=ON | |
cmake --build . --config Release -j $(nproc) | |
- 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: Pack artifacts | |
id: pack_artifacts | |
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} | |
run: | | |
cp LICENSE ./build/bin/ | |
cp $(find . -name "*.so") ./build/bin/ | |
zip -r vulkan-llama-${{ steps.tag.outputs.name }}-bin-ubuntu-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: | |
path: vulkan-llama-${{ steps.tag.outputs.name }}-bin-ubuntu-x64.zip | |
name: vulkan-llama-bin-ubuntu-x64.zip | |
# TODO: build with GGML_NO_METAL because test-backend-ops fail on "Apple Paravirtual device" and I don't know | |
# how to debug it. | |
# ref: https://github.com/ggerganov/llama.cpp/actions/runs/7131777249/job/19420981052#step:5:1124 | |
release: | |
permissions: write-all | |
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} | |
runs-on: ubuntu-latest | |
needs: | |
- ubuntu-latest-cuda-cmake | |
- ubuntu-latest-vulkan-cmake | |
steps: | |
- name: Clone | |
id: checkout | |
uses: actions/checkout@v4 | |
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@v4 | |
with: | |
path: ./artifact | |
- name: Move artifacts | |
id: move_artifacts | |
run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release | |
- 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 | |
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/release')) { | |
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/release/${file}`) | |
}); | |
} | |
} | |
# ubuntu-latest-gcc: | |
# runs-on: ubuntu-latest | |
# | |
# strategy: | |
# matrix: | |
# build: [Debug, Release] | |
# | |
# steps: | |
# - name: Clone | |
# uses: actions/checkout@v4 | |
# | |
# - name: Dependencies | |
# run: | | |
# sudo apt-get update | |
# sudo apt-get install build-essential | |
# sudo apt-get install cmake | |
# | |
# - name: Configure | |
# run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} | |
# | |
# - name: Build | |
# run: | | |
# make | |
# | |
# ubuntu-latest-clang: | |
# runs-on: ubuntu-latest | |
# | |
# strategy: | |
# matrix: | |
# build: [Debug, Release] | |
# | |
# steps: | |
# - name: Clone | |
# uses: actions/checkout@v4 | |
# | |
# - name: Dependencies | |
# run: | | |
# sudo apt-get update | |
# sudo apt-get install build-essential | |
# sudo apt-get install cmake | |
# | |
# - name: Configure | |
# run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang | |
# | |
# - name: Build | |
# run: | | |
# make | |
# | |
# ubuntu-latest-gcc-sanitized: | |
# runs-on: ubuntu-latest | |
# | |
# strategy: | |
# matrix: | |
# sanitizer: [ADDRESS, THREAD, UNDEFINED] | |
# | |
# steps: | |
# - name: Clone | |
# uses: actions/checkout@v4 | |
# | |
# - name: Dependencies | |
# run: | | |
# sudo apt-get update | |
# sudo apt-get install build-essential | |
# sudo apt-get install cmake | |
# | |
# - name: Configure | |
# run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON | |
# | |
# - name: Build | |
# run: | | |
# make | |
# | |
# windows: | |
# runs-on: windows-latest | |
# | |
# strategy: | |
# matrix: | |
# build: [Release] | |
# arch: [Win32, x64] | |
# include: | |
# - arch: Win32 | |
# s2arc: x86 | |
# - arch: x64 | |
# s2arc: x64 | |
# | |
# steps: | |
# - name: Clone | |
# uses: actions/checkout@v4 | |
# | |
# - name: Add msbuild to PATH | |
# uses: microsoft/setup-msbuild@v1 | |
# | |
# - name: Configure | |
# run: > | |
# cmake -S . -B ./build -A ${{ matrix.arch }} | |
# -DCMAKE_BUILD_TYPE=${{ matrix.build }} | |
# | |
# - name: Build | |
# run: | | |
# cd ./build | |
# msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }} | |
# | |
# - name: Upload binaries | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: llama-bin-${{ matrix.arch }} | |
# path: build/bin/${{ matrix.build }} | |
# | |
# windows-blas: | |
# runs-on: windows-latest | |
# | |
# strategy: | |
# matrix: | |
# build: [Release] | |
# arch: [Win32, x64] | |
# blas: [ON] | |
# include: | |
# - arch: Win32 | |
# obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip | |
# s2arc: x86 | |
# - arch: x64 | |
# obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip | |
# s2arc: x64 | |
# | |
# steps: | |
# - name: Clone | |
# uses: actions/checkout@v4 | |
# | |
# - name: Add msbuild to PATH | |
# uses: microsoft/setup-msbuild@v1 | |
# | |
# - name: Fetch OpenBLAS | |
# if: matrix.blas == 'ON' | |
# run: | | |
# C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }} | |
# 7z x blas.zip -oblas -y | |
# copy blas/include/cblas.h . | |
# copy blas/include/openblas_config.h . | |
# echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV | |
# | |
# - name: Configure | |
# run: > | |
# cmake -S . -B ./build -A ${{ matrix.arch }} | |
# -DCMAKE_BUILD_TYPE=${{ matrix.build }} | |
# -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }} | |
# -DCMAKE_LIBRARY_PATH="$env:blasdir/lib" | |
# | |
# - name: Build | |
# run: | | |
# cd ./build | |
# msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }} | |
# | |
# - name: Copy libopenblas.dll | |
# if: matrix.blas == 'ON' | |
# run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }} | |
# | |
# - name: Upload binaries | |
# if: matrix.blas == 'ON' | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: llama-blas-bin-${{ matrix.arch }} | |
# path: build/bin/${{ matrix.build }} | |
# | |
# emscripten: | |
# runs-on: ubuntu-latest | |
# | |
# strategy: | |
# matrix: | |
# build: [Release] | |
# | |
# steps: | |
# - name: Clone | |
# uses: actions/checkout@v4 | |
# | |
# - name: Dependencies | |
# run: | | |
# wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz | |
# tar -xvf master.tar.gz | |
# emsdk-master/emsdk update | |
# emsdk-master/emsdk install latest | |
# emsdk-master/emsdk activate latest | |
# | |
# - name: Configure | |
# run: echo "tmp" | |
# | |
# - name: Build | |
# run: | | |
# pushd emsdk-master | |
# source ./emsdk_env.sh | |
# popd | |
# emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} | |
# make |