From cf09f610cd042185483aead71712ffa0bd313128 Mon Sep 17 00:00:00 2001 From: sasha0552 Date: Wed, 14 Feb 2024 02:09:54 +0000 Subject: [PATCH] Update repositories, reenable ROCm on selfhosted runner, add packages (#24) CI: * Rename actions * Create actions generator * Configure mirrorlist before building * Use work dir inside container * Remove container when stopped * Fix CI exec conditions Misc: * Update repositories * Add useful packages * Update README.md * Add vm shutdown logic --- .ci/actions.py | 28 ++++++ .ci/dependencies.sh | 5 +- .../template/gh-build-iso.yml.jinja2 | 19 ++-- .ci/template/sh-build-iso.yml.jinja2 | 90 +++++++++++++++++++ ...ild-iso-cuda.yml => gh-build-iso-cuda.yml} | 15 ++-- .github/workflows/sh-build-iso-rocm.yml | 88 ++++++++++++++++++ README.md | 4 +- airootfs/home/tori/ComfyUI | 2 +- airootfs/home/tori/automatic | 2 +- airootfs/home/tori/axolotl | 2 +- airootfs/home/tori/koboldcpp | 2 +- airootfs/home/tori/llama.cpp | 2 +- airootfs/home/tori/vllm | 2 +- .../0100-llamacpp-enable-prompt-cache.patch | 6 +- .../0100-vllm-enable-other-archs.patch | 2 +- packages.x86_64.jinja2 | 2 + 16 files changed, 248 insertions(+), 23 deletions(-) create mode 100644 .ci/actions.py rename .github/workflows/build-iso-rocm.yml.disabled => .ci/template/gh-build-iso.yml.jinja2 (75%) create mode 100644 .ci/template/sh-build-iso.yml.jinja2 rename .github/workflows/{build-iso-cuda.yml => gh-build-iso-cuda.yml} (85%) create mode 100644 .github/workflows/sh-build-iso-rocm.yml diff --git a/.ci/actions.py b/.ci/actions.py new file mode 100644 index 0000000..3228c13 --- /dev/null +++ b/.ci/actions.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +import jinja2 + +def main(): + for filename in [ "gh-build-iso", "sh-build-iso" ]: + for type in [ "cuda", "rocm" ]: + # read input file + with open(f".ci/template/{filename}.yml.jinja2", "r") as file: + template = jinja2.Template(file.read()) + + # render template + rendered = template.render(type=type) + + # FIXME: skip if hosted and rocm + if filename == "gh-build-iso" and type == "rocm": + continue + + # FIXME: skip if selfhosted and cuda + if filename == "sh-build-iso" and type == "cuda": + continue + + # write output file + with open(f".github/workflows/{filename}-{type}.yml", "w") as file: + file.write(rendered) + +if __name__ == "__main__": + main() diff --git a/.ci/dependencies.sh b/.ci/dependencies.sh index 28b9ff9..5f2986b 100755 --- a/.ci/dependencies.sh +++ b/.ci/dependencies.sh @@ -17,4 +17,7 @@ pacman-key --init pacman-key --populate # Install required packages -pacman --sync --noconfirm --needed archiso patch python python-jinja rdfind +pacman --sync --noconfirm --needed archiso patch python python-jinja rdfind reflector + +# Configure mirrorlist +reflector --latest 5 --sort rate --save /etc/pacman.d/mirrorlist diff --git a/.github/workflows/build-iso-rocm.yml.disabled b/.ci/template/gh-build-iso.yml.jinja2 similarity index 75% rename from .github/workflows/build-iso-rocm.yml.disabled rename to .ci/template/gh-build-iso.yml.jinja2 index 7311171..9156816 100644 --- a/.github/workflows/build-iso-rocm.yml.disabled +++ b/.ci/template/gh-build-iso.yml.jinja2 @@ -1,8 +1,13 @@ -name: Build ISO (ROCm) +name: Build ISO on hosted runner ({{ "CUDA" if type == "cuda" else "ROCm" }}) on: - - push - - pull_request + push: + branches: + - main + + pull_request: + branches: + - main jobs: build: @@ -23,7 +28,9 @@ jobs: uses: addnab/docker-run-action@v3 with: image: archlinux:latest +{%- raw %} options: --privileged --volume ${{ github.workspace }}:/workspace +{%- endraw %} run: | # Exit on error set -eu @@ -36,12 +43,12 @@ jobs: # Patch mkarchiso .ci/mkarchiso.sh - # Configure to use ROCm - .ci/configure.py rocm + # Configure to use {{ "CUDA" if type == "cuda" else "ROCm" }} + .ci/configure.py {{ type }} popd # Build image - mkarchiso -v -m iso -w /workspace/work -o /workspace/out /workspace + mkarchiso -v -m iso -w /_work -o /workspace/out /workspace - name: Create summary run: | diff --git a/.ci/template/sh-build-iso.yml.jinja2 b/.ci/template/sh-build-iso.yml.jinja2 new file mode 100644 index 0000000..11315ca --- /dev/null +++ b/.ci/template/sh-build-iso.yml.jinja2 @@ -0,0 +1,90 @@ +name: Build ISO on selfhosted runner ({{ "CUDA" if type == "cuda" else "ROCm" }}) + +on: + push: + branches: + - main + + pull_request: + branches: + - main + +jobs: + vm-start: + runs-on: ubuntu-latest + + steps: + - name: Start virtual machine + run: | + # Do nothing for now + exit 0 + + build: + needs: vm-start + runs-on: self-hosted + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Build image + uses: addnab/docker-run-action@v3 + with: + image: archlinux:latest +{%- raw %} + options: --privileged --rm --volume ${{ github.workspace }}:/workspace +{%- endraw %} + run: | + # Exit on error + set -eu + + # Enter project directory + pushd /workspace + # Install dependencies + .ci/dependencies.sh + + # Patch mkarchiso + .ci/mkarchiso.sh + + # Configure to use {{ "CUDA" if type == "cuda" else "ROCm" }} + .ci/configure.py {{ type }} + popd + + # Build image + mkarchiso -v -m iso -w /_work -o /workspace/out /workspace + + - name: Create summary + run: | + # Exit on error + set -eu + + # Print checksums to summary + sha256sum out/* > "$GITHUB_STEP_SUMMARY" + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: archiso-output + path: out/ + + vm-shutdown: + needs: build + runs-on: self-hosted + + steps: + - name: Stop virtual machine + run: | + # Shutdown in 1 minute + sudo shutdown 1 + + vm-shutdown-wait: + needs: vm-shutdown + runs-on: ubuntu-latest + + steps: + - name: Wait until virtual machine is stopped + run: | + # Wait for 2 minutes + sleep 120 diff --git a/.github/workflows/build-iso-cuda.yml b/.github/workflows/gh-build-iso-cuda.yml similarity index 85% rename from .github/workflows/build-iso-cuda.yml rename to .github/workflows/gh-build-iso-cuda.yml index 5c423d7..5385af1 100644 --- a/.github/workflows/build-iso-cuda.yml +++ b/.github/workflows/gh-build-iso-cuda.yml @@ -1,8 +1,13 @@ -name: Build ISO (CUDA) +name: Build ISO on hosted runner (CUDA) on: - - push - - pull_request + push: + branches: + - main + + pull_request: + branches: + - main jobs: build: @@ -41,7 +46,7 @@ jobs: popd # Build image - mkarchiso -v -m iso -w /workspace/work -o /workspace/out /workspace + mkarchiso -v -m iso -w /_work -o /workspace/out /workspace - name: Create summary run: | @@ -55,4 +60,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: archiso-output - path: out/ + path: out/ \ No newline at end of file diff --git a/.github/workflows/sh-build-iso-rocm.yml b/.github/workflows/sh-build-iso-rocm.yml new file mode 100644 index 0000000..3bd32fb --- /dev/null +++ b/.github/workflows/sh-build-iso-rocm.yml @@ -0,0 +1,88 @@ +name: Build ISO on selfhosted runner (ROCm) + +on: + push: + branches: + - main + + pull_request: + branches: + - main + +jobs: + vm-start: + runs-on: ubuntu-latest + + steps: + - name: Start virtual machine + run: | + # Do nothing for now + exit 0 + + build: + needs: vm-start + runs-on: self-hosted + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Build image + uses: addnab/docker-run-action@v3 + with: + image: archlinux:latest + options: --privileged --rm --volume ${{ github.workspace }}:/workspace + run: | + # Exit on error + set -eu + + # Enter project directory + pushd /workspace + # Install dependencies + .ci/dependencies.sh + + # Patch mkarchiso + .ci/mkarchiso.sh + + # Configure to use ROCm + .ci/configure.py rocm + popd + + # Build image + mkarchiso -v -m iso -w /_work -o /workspace/out /workspace + + - name: Create summary + run: | + # Exit on error + set -eu + + # Print checksums to summary + sha256sum out/* > "$GITHUB_STEP_SUMMARY" + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: archiso-output + path: out/ + + vm-shutdown: + needs: build + runs-on: self-hosted + + steps: + - name: Stop virtual machine + run: | + # Shutdown in 1 minute + sudo shutdown 1 + + vm-shutdown-wait: + needs: vm-shutdown + runs-on: ubuntu-latest + + steps: + - name: Wait until virtual machine is stopped + run: | + # Wait for 2 minutes + sleep 120 \ No newline at end of file diff --git a/README.md b/README.md index 8b0debc..bc4a091 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ If you would like to see another AI-related project included in ToriLinux, pleas To use ToriLinux: 1. Install [Ventoy](https://ventoy.net/en/doc_start.html) on a USB drive. -2. Download the latest ISO from workflows ([NVIDIA](https://github.com/sasha0552/ToriLinux/actions/workflows/build-iso-cuda.yml?query=branch%3Amain) / [AMD](https://github.com/sasha0552/ToriLinux/actions/workflows/build-iso-rocm.yml?query=branch%3Amain)) and copy it to the USB drive. +2. Download the latest ISO from workflows ([NVIDIA](https://github.com/sasha0552/ToriLinux/actions/workflows/gh-build-iso-cuda?query=branch%3Amain) / [AMD](https://github.com/sasha0552/ToriLinux/actions/workflows/sh-build-iso-rocm.yml?query=branch%3Amain)) and copy it to the USB drive. 3. Boot from the USB drive (select it as the boot device in BIOS/UEFI). 4. Log in with the username `tori` and password `tori`. You can also use [SSH](https://en.wikipedia.org/wiki/Secure_Shell). @@ -33,3 +33,5 @@ Note that you need pre-downloaded models on a local hard drive or NFS server, or Note that following projects is not available on ROCm version: * [axolotl](https://github.com/OpenAccess-AI-Collective/axolotl) * [vllm](https://github.com/vllm-project/vllm) + +The server for building the ROCm version is provided by [@Sepera-okeq](https://github.com/Sepera-okeq/). diff --git a/airootfs/home/tori/ComfyUI b/airootfs/home/tori/ComfyUI index fd73b5e..38b7ac6 160000 --- a/airootfs/home/tori/ComfyUI +++ b/airootfs/home/tori/ComfyUI @@ -1 +1 @@ -Subproject commit fd73b5ee3a5af90119250f6b8308fdf03932128e +Subproject commit 38b7ac6e269e6ecc5bdd6fefdfb2fb1185b09c9d diff --git a/airootfs/home/tori/automatic b/airootfs/home/tori/automatic index 376bace..3c95267 160000 --- a/airootfs/home/tori/automatic +++ b/airootfs/home/tori/automatic @@ -1 +1 @@ -Subproject commit 376bace04fdcc24c8a4d886f2b1b9e581cbdc754 +Subproject commit 3c952675fefd2c94b817940ffbd4cd94fd5876c9 diff --git a/airootfs/home/tori/axolotl b/airootfs/home/tori/axolotl index 9bca7db..8430db2 160000 --- a/airootfs/home/tori/axolotl +++ b/airootfs/home/tori/axolotl @@ -1 +1 @@ -Subproject commit 9bca7db1332219695002e8812925b243408e24a8 +Subproject commit 8430db22e29d613bc4151af830e7916c884b61ec diff --git a/airootfs/home/tori/koboldcpp b/airootfs/home/tori/koboldcpp index 22a4d84..d1aff0e 160000 --- a/airootfs/home/tori/koboldcpp +++ b/airootfs/home/tori/koboldcpp @@ -1 +1 @@ -Subproject commit 22a4d84050559c2db10834a7683d4c58166561dd +Subproject commit d1aff0e96475a3bae6850bc620488c762a642061 diff --git a/airootfs/home/tori/llama.cpp b/airootfs/home/tori/llama.cpp index 44fbe34..099afc6 160000 --- a/airootfs/home/tori/llama.cpp +++ b/airootfs/home/tori/llama.cpp @@ -1 +1 @@ -Subproject commit 44fbe34360dd760f9e68b4271f21533436397f84 +Subproject commit 099afc6274c859ca67146e725839f2d97a5ef313 diff --git a/airootfs/home/tori/vllm b/airootfs/home/tori/vllm index 3711811..5638364 160000 --- a/airootfs/home/tori/vllm +++ b/airootfs/home/tori/vllm @@ -1 +1 @@ -Subproject commit 3711811b1d2956e83e626c72f0e1607f2dfbc8fb +Subproject commit 563836496abc0914c212b693130f80be25926564 diff --git a/airootfs/root/customize_airootfs/patches/0100-llamacpp-enable-prompt-cache.patch b/airootfs/root/customize_airootfs/patches/0100-llamacpp-enable-prompt-cache.patch index 1113cd4..2fc7928 100644 --- a/airootfs/root/customize_airootfs/patches/0100-llamacpp-enable-prompt-cache.patch +++ b/airootfs/root/customize_airootfs/patches/0100-llamacpp-enable-prompt-cache.patch @@ -1,9 +1,9 @@ --- a/examples/server/oai.hpp +++ b/examples/server/oai.hpp -@@ -31,7 +31,7 @@ inline static json oaicompat_completion_params_parse( +@@ -35,7 +35,7 @@ inline static json oaicompat_completion_params_parse( llama_sampling_params default_sparams; llama_params["model"] = json_value(body, "model", std::string("unknown")); - llama_params["prompt"] = format_chatml(body["messages"]); // OpenAI 'messages' to llama.cpp 'prompt' + llama_params["prompt"] = formatted_prompt; - llama_params["cache_prompt"] = json_value(body, "cache_prompt", false); + llama_params["cache_prompt"] = json_value(body, "cache_prompt", true); llama_params["temperature"] = json_value(body, "temperature", 0.0); @@ -11,7 +11,7 @@ llama_params["top_p"] = json_value(body, "top_p", 1.0); --- a/examples/server/server.cpp +++ b/examples/server/server.cpp -@@ -525,7 +525,7 @@ struct llama_server_context +@@ -526,7 +526,7 @@ struct llama_server_context } slot->params.stream = json_value(data, "stream", false); diff --git a/airootfs/root/customize_airootfs/patches/0100-vllm-enable-other-archs.patch b/airootfs/root/customize_airootfs/patches/0100-vllm-enable-other-archs.patch index 8398168..d7d7c24 100644 --- a/airootfs/root/customize_airootfs/patches/0100-vllm-enable-other-archs.patch +++ b/airootfs/root/customize_airootfs/patches/0100-vllm-enable-other-archs.patch @@ -6,7 +6,7 @@ # Supported NVIDIA GPU architectures. -NVIDIA_SUPPORTED_ARCHS = {"7.0", "7.5", "8.0", "8.6", "8.9", "9.0"} +NVIDIA_SUPPORTED_ARCHS = {"6.0", "6.1", "7.0", "7.5", "8.0", "8.6", "8.9", "9.0"} - ROCM_SUPPORTED_ARCHS = {"gfx90a", "gfx942"} + ROCM_SUPPORTED_ARCHS = {"gfx90a", "gfx942", "gfx1100"} # SUPPORTED_ARCHS = NVIDIA_SUPPORTED_ARCHS.union(ROCM_SUPPORTED_ARCHS) @@ -222,9 +222,9 @@ if _is_cuda() and not compute_capabilities: diff --git a/packages.x86_64.jinja2 b/packages.x86_64.jinja2 index 50f9592..354e4d5 100644 --- a/packages.x86_64.jinja2 +++ b/packages.x86_64.jinja2 @@ -20,7 +20,9 @@ mkinitcpio-nfs-utils nano ncdu neofetch +net-tools nfs-utils +ntfs-3g nvtop openssh progress