From ca9e4964cd25dd7c4f5653e62ec27403c8be07a2 Mon Sep 17 00:00:00 2001 From: Kirill Starkov Date: Tue, 9 Jan 2024 13:05:58 +0800 Subject: [PATCH] add cicl cache --- .github/scripts/build_base_docker.sh | 31 +++++++++++++++++ .github/scripts/cicl_docker_injection.sh | 12 +++++++ .github/scripts/requirements.txt | 2 ++ .github/workflows/build.yml | 42 +++++------------------- 4 files changed, 53 insertions(+), 34 deletions(-) create mode 100755 .github/scripts/build_base_docker.sh create mode 100755 .github/scripts/cicl_docker_injection.sh create mode 100644 .github/scripts/requirements.txt diff --git a/.github/scripts/build_base_docker.sh b/.github/scripts/build_base_docker.sh new file mode 100755 index 000000000..b2b2b64a6 --- /dev/null +++ b/.github/scripts/build_base_docker.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +REPO_DIR=$(realpath $SCRIPT_DIR/../..) + +ORIGIN_DOCKERFILE=${REPO_DIR}/Dockerfile +BASE_DOCKERFILE=${SCRIPT_DIR}/Dockerfile + +BASE_IMAGE=$(cat $ORIGIN_DOCKERFILE | grep FROM | head -1 | awk '{print $2}') +echo FROM $BASE_IMAGE > $BASE_DOCKERFILE + +echo ENV INSTALL_OPTIONAL=TRUE >> $BASE_DOCKERFILE +echo ENV FLASH_ATTENTION_FORCE_BUILD=TRUE >> $BASE_DOCKERFILE + +echo RUN apt-get update >> $BASE_DOCKERFILE +echo 'RUN DEBIAN_FRONTEND="noninteractive" TZ=Etc/UTC apt-get install -y git python3 python3-pip python3-packaging && rm -rf /var/lib/{apt,dpkg,cache,log}' >> $BASE_DOCKERFILE + +TORCH_STR=$(cat $ORIGIN_DOCKERFILE | grep torch==) + +echo ${TORCH_STR} >> $BASE_DOCKERFILE +echo RUN pip install ninja >> $BASE_DOCKERFILE + +REQUIREMENTS=$(cat $SCRIPT_DIR/requirements.txt) +IFS=$'\n' read -rd '' -a REQUIREMENTS <<<"$REQUIREMENTS" + +for requirement in "${REQUIREMENTS[@]}" +do + echo "RUN MAX_JOBS=8 pip install -v $requirement" >> $BASE_DOCKERFILE +done + +docker buildx build --platform linux/amd64 -t ghcr.io/smallcloud/refact_base_image:latest --push -f $BASE_DOCKERFILE $REPO_DIR diff --git a/.github/scripts/cicl_docker_injection.sh b/.github/scripts/cicl_docker_injection.sh new file mode 100755 index 000000000..1a1f0a3ce --- /dev/null +++ b/.github/scripts/cicl_docker_injection.sh @@ -0,0 +1,12 @@ +#/bin/bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +REPO_DIR=$(realpath $SCRIPT_DIR/../..) + +ORIGIN_DOCKERFILE=${REPO_DIR}/Dockerfile +BASE_IMAGE=$(cat $ORIGIN_DOCKERFILE | grep FROM | head -1 | awk '{print $2}') + +CACHE_IMAGE="ghcr.io/smallcloud/refact_base_image:latest" + +sed -i "s!${BASE_IMAGE}!${CACHE_IMAGE}!" ${ORIGIN_DOCKERFILE} + diff --git a/.github/scripts/requirements.txt b/.github/scripts/requirements.txt new file mode 100644 index 000000000..c568cb3fd --- /dev/null +++ b/.github/scripts/requirements.txt @@ -0,0 +1,2 @@ +git+https://github.com/smallcloudai/flash-attention@feat/alibi +git+https://github.com/smallcloudai/vllm@refact_model_deps diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 20de175b0..5aef8f0d9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,8 +18,8 @@ jobs: run: | echo "now_tag=RELEASE.$(TZ=UTC date +'%Y-%m-%dT%H-%M-%SZ')" >> "$GITHUB_OUTPUT" - amd64: - name: Build amd64 + cicl: + name: Cicl runs-on: ubuntu-latest needs: [setup-vars] outputs: @@ -33,13 +33,18 @@ jobs: sudo rm -rf /usr/local/lib/android sudo rm -rf /opt/ghc + - name: Inject cache docker image + run: | + ls -la && exit 1 + ./.github/scripts/cicl_docker_injection.sh + - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Build and push + - name: Build uses: docker/build-push-action@v4 with: push: false @@ -48,34 +53,3 @@ jobs: smallcloud/refact_self_hosting:RELEASE.${{ needs.setup-vars.outputs.now_tag }} platforms: | linux/amd64 -# commented temporary until cpu is not supported -# arm64: -# name: Build arm64 -# runs-on: ubuntu-latest -# needs: [setup-vars] -# outputs: -# version: ${{ steps.properties.outputs.version }} -# changelog: ${{ steps.properties.outputs.changelog }} -# steps: -# # Free GitHub Actions Environment Disk Space -# - name: Maximize Build Space -# run: | -# sudo rm -rf /usr/share/dotnet -# sudo rm -rf /usr/local/lib/android -# sudo rm -rf /opt/ghc -# -# - name: Set up QEMU -# uses: docker/setup-qemu-action@v2 -# -# - name: Set up Docker Buildx -# uses: docker/setup-buildx-action@v2 -# -# - name: Build and push -# uses: docker/build-push-action@v4 -# with: -# push: false -# tags: | -# smallcloud/refact_self_hosting:latest -# smallcloud/refact_self_hosting:RELEASE.${{ needs.setup-vars.outputs.now_tag }} -# platforms: | -# linux/arm64