feat(arm64): enable single-binary builds #4755
Workflow file for this run
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: Build and Release | |
on: | |
- push | |
- pull_request | |
env: | |
GRPC_VERSION: v1.64.0 | |
permissions: | |
contents: write | |
concurrency: | |
group: ci-releases-${{ github.head_ref || github.ref }}-${{ github.repository }} | |
cancel-in-progress: true | |
jobs: | |
build-linux-arm: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: '1.21.x' | |
cache: false | |
- name: Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install build-essential ffmpeg protobuf-compiler ccache | |
sudo apt-get install -qy binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
- name: Install CUDA Dependencies | |
run: | | |
curl -O https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/cross-linux-aarch64/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 -y cuda-cross-aarch64 cuda-nvcc-cross-aarch64-${CUDA_VERSION} libcublas-cross-aarch64-${CUDA_VERSION} | |
env: | |
CUDA_VERSION: 12-4 | |
- name: Cache grpc | |
id: cache-grpc | |
uses: actions/cache@v4 | |
with: | |
path: grpc | |
key: ${{ runner.os }}-arm-grpc-${{ env.GRPC_VERSION }} | |
- name: Build grpc | |
if: steps.cache-grpc.outputs.cache-hit != 'true' | |
run: | | |
git clone --recurse-submodules -b ${{ env.GRPC_VERSION }} --depth 1 --shallow-submodules https://github.com/grpc/grpc && \ | |
cd grpc && mkdir -p cmake/build && cd cmake/build && cmake -DgRPC_INSTALL=ON \ | |
-DgRPC_BUILD_TESTS=OFF \ | |
../.. && sudo make --jobs 5 --output-sync=target | |
- name: Install gRPC | |
run: | | |
GNU_HOST=aarch64-linux-gnu | |
C_COMPILER_ARM_LINUX=$GNU_HOST-gcc | |
CXX_COMPILER_ARM_LINUX=$GNU_HOST-g++ | |
CROSS_TOOLCHAIN=/usr/$GNU_HOST | |
CROSS_STAGING_PREFIX=$CROSS_TOOLCHAIN/stage | |
CMAKE_CROSS_TOOLCHAIN=/tmp/arm.toolchain.cmake | |
# https://cmake.org/cmake/help/v3.13/manual/cmake-toolchains.7.html#cross-compiling-for-linux | |
echo "set(CMAKE_SYSTEM_NAME Linux)" >> $CMAKE_CROSS_TOOLCHAIN && \ | |
echo "set(CMAKE_SYSTEM_PROCESSOR arm)" >> $CMAKE_CROSS_TOOLCHAIN && \ | |
echo "set(CMAKE_STAGING_PREFIX $CROSS_STAGING_PREFIX)" >> $CMAKE_CROSS_TOOLCHAIN && \ | |
echo "set(CMAKE_SYSROOT ${CROSS_TOOLCHAIN}/sysroot)" >> $CMAKE_CROSS_TOOLCHAIN && \ | |
echo "set(CMAKE_C_COMPILER /usr/bin/$C_COMPILER_ARM_LINUX)" >> $CMAKE_CROSS_TOOLCHAIN && \ | |
echo "set(CMAKE_CXX_COMPILER /usr/bin/$CXX_COMPILER_ARM_LINUX)" >> $CMAKE_CROSS_TOOLCHAIN && \ | |
echo "set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)" >> $CMAKE_CROSS_TOOLCHAIN && \ | |
echo "set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)" >> $CMAKE_CROSS_TOOLCHAIN && \ | |
echo "set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)" >> $CMAKE_CROSS_TOOLCHAIN && \ | |
echo "set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)" >> $CMAKE_CROSS_TOOLCHAIN | |
GRPC_DIR=$PWD/grpc | |
cd grpc && cd cmake/build && sudo make --jobs 5 --output-sync=target install && \ | |
GRPC_CROSS_BUILD_DIR=$GRPC_DIR/cmake/cross_build && \ | |
mkdir -p $GRPC_CROSS_BUILD_DIR && \ | |
cd $GRPC_CROSS_BUILD_DIR && \ | |
cmake -DCMAKE_TOOLCHAIN_FILE=$CMAKE_CROSS_TOOLCHAIN \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_INSTALL_PREFIX=$CROSS_TOOLCHAIN/grpc_install \ | |
../.. && \ | |
sudo make -j`nproc` install | |
- name: Build | |
id: build | |
run: | | |
GNU_HOST=aarch64-linux-gnu | |
C_COMPILER_ARM_LINUX=$GNU_HOST-gcc | |
CXX_COMPILER_ARM_LINUX=$GNU_HOST-g++ | |
CROSS_TOOLCHAIN=/usr/$GNU_HOST | |
CROSS_STAGING_PREFIX=$CROSS_TOOLCHAIN/stage | |
CMAKE_CROSS_TOOLCHAIN=/tmp/arm.toolchain.cmake | |
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@8ba23be9613c672d40ae261d2a1335d639bdd59b | |
go install google.golang.org/protobuf/cmd/[email protected] | |
export PATH=$PATH:$GOPATH/bin | |
export PATH=/usr/local/cuda/bin:$PATH | |
GO_TAGS=p2p GOOS=linux GOARCH=arm64 CMAKE_ARGS="-DProtobuf_DIR=$CROSS_STAGING_PREFIX/lib/cmake/protobuf -DgRPC_DIR=$CROSS_STAGING_PREFIX/lib/cmake/grpc -DCMAKE_TOOLCHAIN_FILE=$CMAKE_CROSS_TOOLCHAIN -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++" make dist-aarch64 | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: LocalAI-linux-aarch64 | |
path: release/ | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
release/* | |
build-linux: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Release space from worker | |
run: | | |
echo "Listing top largest packages" | |
pkgs=$(dpkg-query -Wf '${Installed-Size}\t${Package}\t${Status}\n' | awk '$NF == "installed"{print $1 "\t" $2}' | sort -nr) | |
head -n 30 <<< "${pkgs}" | |
echo | |
df -h | |
echo | |
sudo apt-get remove -y '^llvm-.*|^libllvm.*' || true | |
sudo apt-get remove --auto-remove android-sdk-platform-tools || true | |
sudo apt-get purge --auto-remove android-sdk-platform-tools || true | |
sudo rm -rf /usr/local/lib/android | |
sudo apt-get remove -y '^dotnet-.*|^aspnetcore-.*' || true | |
sudo rm -rf /usr/share/dotnet | |
sudo apt-get remove -y '^mono-.*' || true | |
sudo apt-get remove -y '^ghc-.*' || true | |
sudo apt-get remove -y '.*jdk.*|.*jre.*' || true | |
sudo apt-get remove -y 'php.*' || true | |
sudo apt-get remove -y hhvm powershell firefox monodoc-manual msbuild || true | |
sudo apt-get remove -y '^google-.*' || true | |
sudo apt-get remove -y azure-cli || true | |
sudo apt-get remove -y '^mongo.*-.*|^postgresql-.*|^mysql-.*|^mssql-.*' || true | |
sudo apt-get remove -y '^gfortran-.*' || true | |
sudo apt-get remove -y microsoft-edge-stable || true | |
sudo apt-get remove -y firefox || true | |
sudo apt-get remove -y powershell || true | |
sudo apt-get remove -y r-base-core || true | |
sudo apt-get autoremove -y | |
sudo apt-get clean | |
echo | |
echo "Listing top largest packages" | |
pkgs=$(dpkg-query -Wf '${Installed-Size}\t${Package}\t${Status}\n' | awk '$NF == "installed"{print $1 "\t" $2}' | sort -nr) | |
head -n 30 <<< "${pkgs}" | |
echo | |
sudo rm -rfv build || true | |
sudo rm -rf /usr/share/dotnet || true | |
sudo rm -rf /opt/ghc || true | |
sudo rm -rf "/usr/local/share/boost" || true | |
sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true | |
df -h | |
- name: Clone | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: '1.21.x' | |
cache: false | |
- name: Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install build-essential ffmpeg protobuf-compiler ccache | |
- name: Install CUDA Dependencies | |
run: | | |
curl -O https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/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 -y cuda-nvcc-${CUDA_VERSION} libcublas-dev-${CUDA_VERSION} | |
env: | |
CUDA_VERSION: 12-3 | |
- name: "Install Hipblas" | |
env: | |
ROCM_VERSION: "6.1" | |
AMDGPU_VERSION: "6.1" | |
run: | | |
set -ex | |
sudo apt-get update | |
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl libnuma-dev gnupg | |
curl -sL https://repo.radeon.com/rocm/rocm.gpg.key | sudo apt-key add - | |
printf "deb [arch=amd64] https://repo.radeon.com/rocm/apt/$ROCM_VERSION/ jammy main" | sudo tee /etc/apt/sources.list.d/rocm.list | |
printf "deb [arch=amd64] https://repo.radeon.com/amdgpu/$AMDGPU_VERSION/ubuntu jammy main" | sudo tee /etc/apt/sources.list.d/amdgpu.list | |
printf 'Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600' | sudo tee /etc/apt/preferences.d/rocm-pin-600 | |
sudo apt-get update | |
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \ | |
hipblas-dev rocm-dev \ | |
rocblas-dev | |
sudo apt-get clean | |
sudo rm -rf /var/lib/apt/lists/* | |
sudo ldconfig | |
- name: Cache grpc | |
id: cache-grpc | |
uses: actions/cache@v4 | |
with: | |
path: grpc | |
key: ${{ runner.os }}-grpc-${{ env.GRPC_VERSION }} | |
- name: Build grpc | |
if: steps.cache-grpc.outputs.cache-hit != 'true' | |
run: | | |
git clone --recurse-submodules -b ${{ env.GRPC_VERSION }} --depth 1 --shallow-submodules https://github.com/grpc/grpc && \ | |
cd grpc && mkdir -p cmake/build && cd cmake/build && cmake -DgRPC_INSTALL=ON \ | |
-DgRPC_BUILD_TESTS=OFF \ | |
../.. && sudo make --jobs 5 --output-sync=target | |
- name: Install gRPC | |
run: | | |
cd grpc && cd cmake/build && sudo make --jobs 5 --output-sync=target install | |
- name: Build | |
id: build | |
run: | | |
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@8ba23be9613c672d40ae261d2a1335d639bdd59b | |
go install google.golang.org/protobuf/cmd/[email protected] | |
export PATH=$PATH:$GOPATH/bin | |
export PATH=/usr/local/cuda/bin:$PATH | |
export PATH=/opt/rocm/bin:$PATH | |
GO_TAGS=p2p make dist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: LocalAI-linux | |
path: release/ | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
release/* | |
build-stablediffusion: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: '1.21.x' | |
cache: false | |
- name: Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y --no-install-recommends libopencv-dev protobuf-compiler ccache | |
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@8ba23be9613c672d40ae261d2a1335d639bdd59b | |
go install google.golang.org/protobuf/cmd/[email protected] | |
- name: Build stablediffusion | |
run: | | |
export PATH=$PATH:$GOPATH/bin | |
make backend-assets/grpc/stablediffusion | |
mkdir -p release && cp backend-assets/grpc/stablediffusion release | |
env: | |
GO_TAGS: stablediffusion | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: stablediffusion | |
path: release/ | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
release/* | |
build-macOS-arm64: | |
runs-on: macos-14 | |
steps: | |
- name: Clone | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: '1.21.x' | |
cache: false | |
- name: Dependencies | |
run: | | |
brew install protobuf grpc | |
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@8ba23be9613c672d40ae261d2a1335d639bdd59b | |
go install google.golang.org/protobuf/cmd/[email protected] | |
- name: Build | |
id: build | |
run: | | |
export C_INCLUDE_PATH=/usr/local/include | |
export CPLUS_INCLUDE_PATH=/usr/local/include | |
export PATH=$PATH:$GOPATH/bin | |
GO_TAGS=p2p make dist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: LocalAI-MacOS-arm64 | |
path: release/ | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
release/* |