From e0f9138c176f3f08af8e6e10a5be6ef38e4c02fa Mon Sep 17 00:00:00 2001 From: sasha0552 Date: Tue, 26 Mar 2024 00:37:52 +0000 Subject: [PATCH] Improve scripts, add new iso build mode - "empty", update repositories (#29) * Improve scripts * Add new iso build mode - "empty" * Update repositories --- .ci/actions.py | 35 +++++----- .ci/configure.py | 24 ++++--- .ci/empty.sh | 5 ++ .ci/template/gh-build-iso.yml.jinja2 | 19 ++++-- .ci/template/sh-build-iso.yml.jinja2 | 21 ++++-- .github/workflows/gh-build-iso-cuda-empty.yml | 61 +++++++++++++++++ .github/workflows/gh-build-iso-cuda.yml | 6 +- .github/workflows/gh-build-iso-rocm-empty.yml | 65 +++++++++++++++++++ .github/workflows/sh-build-iso-rocm.yml | 8 ++- .gitignore | 2 + .gitignore.jinja2 | 3 +- airootfs/etc/sudoers | 2 +- 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/text-generation-webui | 2 +- airootfs/home/tori/vllm | 2 +- airootfs/root/customize_airootfs.sh.jinja2 | 18 ++--- .../0100-llamacpp-enable-prompt-cache.patch | 15 +---- .../0100-vllm-enable-other-archs.patch | 23 ------- .../scripts/0100-automatic-patches.sh.jinja2 | 2 +- .../scripts/0100-koboldcpp-patches.sh.jinja2 | 2 +- .../scripts/0100-vllm-patches.sh | 8 --- .../1000-automatic-dependencies.sh.jinja2 | 2 +- .../1000-axolotl-dependencies.sh.jinja2 | 2 +- .../1000-comfyui-dependencies.sh.jinja2 | 2 +- ...-sillytavern-extras-dependencies.sh.jinja2 | 4 +- ...xt-generation-webui-dependencies.sh.jinja2 | 4 +- .../scripts/1000-vllm-dependencies.sh.jinja2 | 48 -------------- .../scripts/9999-cleanup.sh.jinja2 | 2 +- packages.x86_64.jinja2 | 4 +- profiledef.sh => profiledef.sh.jinja2 | 8 +-- 34 files changed, 243 insertions(+), 166 deletions(-) create mode 100755 .ci/empty.sh create mode 100644 .github/workflows/gh-build-iso-cuda-empty.yml create mode 100644 .github/workflows/gh-build-iso-rocm-empty.yml delete mode 100644 airootfs/root/customize_airootfs/patches/0100-vllm-enable-other-archs.patch delete mode 100644 airootfs/root/customize_airootfs/scripts/0100-vllm-patches.sh delete mode 100644 airootfs/root/customize_airootfs/scripts/1000-vllm-dependencies.sh.jinja2 rename profiledef.sh => profiledef.sh.jinja2 (58%) diff --git a/.ci/actions.py b/.ci/actions.py index 3228c13..15b8137 100644 --- a/.ci/actions.py +++ b/.ci/actions.py @@ -2,27 +2,28 @@ 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()) +def render_template(input_path, output_path, **options): + # read input file + with open(input_path, "r") as file: + template = jinja2.Template(file.read(), lstrip_blocks=True, trim_blocks=True) - # render template - rendered = template.render(type=type) + # render template + rendered = template.render(**options) - # FIXME: skip if hosted and rocm - if filename == "gh-build-iso" and type == "rocm": - continue + # write output file + with open(output_path, "w") as file: + file.write(rendered) - # FIXME: skip if selfhosted and cuda - if filename == "sh-build-iso" and type == "cuda": - continue +def main(): + # define directories + i = ".ci/template" + o = ".github/workflows" - # write output file - with open(f".github/workflows/{filename}-{type}.yml", "w") as file: - file.write(rendered) + # render templates + render_template(f"{i}/gh-build-iso.yml.jinja2", f"{o}/gh-build-iso-cuda.yml" , platform="cuda", type="normal") + render_template(f"{i}/gh-build-iso.yml.jinja2", f"{o}/gh-build-iso-cuda-empty.yml", platform="cuda", type="empty") + render_template(f"{i}/sh-build-iso.yml.jinja2", f"{o}/sh-build-iso-rocm.yml" , platform="rocm", type="normal") + render_template(f"{i}/gh-build-iso.yml.jinja2", f"{o}/gh-build-iso-rocm-empty.yml", platform="rocm", type="empty") if __name__ == "__main__": main() diff --git a/.ci/configure.py b/.ci/configure.py index 6d780d0..8b2dba7 100755 --- a/.ci/configure.py +++ b/.ci/configure.py @@ -8,7 +8,7 @@ def render_template(filepath, **options): if filepath.endswith(".jinja2"): # read input file with open(filepath, "r") as file: - template = jinja2.Template(file.read()) + template = jinja2.Template(file.read(), lstrip_blocks=True, trim_blocks=True) # render template rendered = template.render(**options) @@ -19,14 +19,18 @@ def render_template(filepath, **options): def main(): # by default, use cuda - cuda = True - rocm = False + platform = "cuda" - # enable rocm if specified - if len(sys.argv) == 2: - if sys.argv[1] == "rocm": - cuda = False - rocm = True + # and normal iso + type = "normal" + + # set platform + if len(sys.argv) >= 2: + platform = sys.argv[1] + + # set type + if len(sys.argv) >= 3: + type = sys.argv[2] # list of rendered files rendered = [] @@ -37,10 +41,10 @@ def main(): rendered.sort() # render file - render_template(filepath, CUDA=cuda, ROCm=rocm, rendered=rendered) + render_template(filepath, platform=platform, type=type, rendered=rendered) # add output file to rendered list - rendered.append(filepath[:-7]) + rendered.append(filepath[:-7].replace("\\", "/")) # print status print(f"File '{filepath}' rendered successfully") diff --git a/.ci/empty.sh b/.ci/empty.sh new file mode 100755 index 0000000..2604c8b --- /dev/null +++ b/.ci/empty.sh @@ -0,0 +1,5 @@ +#!/bin/sh +set -eu + +rm -fr "airootfs/home" +rm -fr "airootfs/root/customize_airootfs" diff --git a/.ci/template/gh-build-iso.yml.jinja2 b/.ci/template/gh-build-iso.yml.jinja2 index 9156816..2d8e583 100644 --- a/.ci/template/gh-build-iso.yml.jinja2 +++ b/.ci/template/gh-build-iso.yml.jinja2 @@ -1,4 +1,4 @@ -name: Build ISO on hosted runner ({{ "CUDA" if type == "cuda" else "ROCm" }}) +name: Build ISO on hosted runner ({{ "CUDA" if platform == "cuda" else "ROCm" }}, {{ type }}) on: push: @@ -14,23 +14,27 @@ jobs: runs-on: ubuntu-latest steps: +{% if type != "empty" or platform == "rocm" %} - name: Cleanup uses: rokibhasansagar/slimhub_actions@main with: retain: "docker_buildkit,docker_imgcache" +{% endif %} - name: Checkout repository uses: actions/checkout@v4 +{% if type != "empty" %} with: submodules: recursive +{% endif %} - name: Build image uses: addnab/docker-run-action@v3 with: image: archlinux:latest -{%- raw %} +{% raw %} options: --privileged --volume ${{ github.workspace }}:/workspace -{%- endraw %} +{% endraw %} run: | # Exit on error set -eu @@ -43,8 +47,13 @@ jobs: # Patch mkarchiso .ci/mkarchiso.sh - # Configure to use {{ "CUDA" if type == "cuda" else "ROCm" }} - .ci/configure.py {{ type }} + {% if type == "empty" %} + # Remove repositories + .ci/empty.sh + {% endif %} + + # Configure to use {{ "CUDA" if platform == "cuda" else "ROCm" }} + .ci/configure.py {{ platform }} {{ type }} popd # Build image diff --git a/.ci/template/sh-build-iso.yml.jinja2 b/.ci/template/sh-build-iso.yml.jinja2 index 54ef8a7..3e8921c 100644 --- a/.ci/template/sh-build-iso.yml.jinja2 +++ b/.ci/template/sh-build-iso.yml.jinja2 @@ -1,4 +1,4 @@ -name: Build ISO on selfhosted runner ({{ "CUDA" if type == "cuda" else "ROCm" }}) +name: Build ISO on selfhosted runner ({{ "CUDA" if type == "cuda" else "ROCm" }}, {{ type }}) on: push: @@ -19,6 +19,7 @@ jobs: run: | # Create ssh directory mkdir ~/.ssh + {% raw %} # Save ssh config echo "${{ secrets.SSH_CONFIG }}" | base64 -d > ~/.ssh/config @@ -29,6 +30,7 @@ jobs: # Save ssh private key echo "${{ secrets.SSH_PRIVATE_KEY }}" | base64 -d > /tmp/private.key {% endraw %} + # Fix permissions for private key chmod 600 /tmp/private.key @@ -47,16 +49,18 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 +{% if type != "empty" %} with: submodules: recursive +{% endif %} - name: Build image uses: addnab/docker-run-action@v3 with: image: archlinux:latest -{%- raw %} +{% raw %} options: --privileged --rm --volume ${{ github.workspace }}:/workspace -{%- endraw %} +{% endraw %} run: | # Exit on error set -eu @@ -69,8 +73,13 @@ jobs: # Patch mkarchiso .ci/mkarchiso.sh - # Configure to use {{ "CUDA" if type == "cuda" else "ROCm" }} - .ci/configure.py {{ type }} + {% if type == "empty" %} + # Remove repositories + .ci/empty.sh + {% endif %} + + # Configure to use {{ "CUDA" if platform == "cuda" else "ROCm" }} + .ci/configure.py {{ platform }} {{ type }} popd # Build image @@ -100,6 +109,7 @@ jobs: run: | # Create ssh directory mkdir ~/.ssh + {% raw %} # Save ssh config echo "${{ secrets.SSH_CONFIG }}" | base64 -d > ~/.ssh/config @@ -110,6 +120,7 @@ jobs: # Save ssh private key echo "${{ secrets.SSH_PRIVATE_KEY }}" | base64 -d > /tmp/private.key {% endraw %} + # Fix permissions for private key chmod 600 /tmp/private.key diff --git a/.github/workflows/gh-build-iso-cuda-empty.yml b/.github/workflows/gh-build-iso-cuda-empty.yml new file mode 100644 index 0000000..c7d2325 --- /dev/null +++ b/.github/workflows/gh-build-iso-cuda-empty.yml @@ -0,0 +1,61 @@ +name: Build ISO on hosted runner (CUDA, empty) + +on: + push: + branches: + - main + + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build image + uses: addnab/docker-run-action@v3 + with: + image: archlinux:latest + + options: --privileged --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 + + # Remove repositories + .ci/empty.sh + + # Configure to use CUDA + .ci/configure.py cuda empty + 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/ \ No newline at end of file diff --git a/.github/workflows/gh-build-iso-cuda.yml b/.github/workflows/gh-build-iso-cuda.yml index 5385af1..ecc11b3 100644 --- a/.github/workflows/gh-build-iso-cuda.yml +++ b/.github/workflows/gh-build-iso-cuda.yml @@ -1,4 +1,4 @@ -name: Build ISO on hosted runner (CUDA) +name: Build ISO on hosted runner (CUDA, normal) on: push: @@ -28,6 +28,7 @@ jobs: uses: addnab/docker-run-action@v3 with: image: archlinux:latest + options: --privileged --volume ${{ github.workspace }}:/workspace run: | # Exit on error @@ -41,8 +42,9 @@ jobs: # Patch mkarchiso .ci/mkarchiso.sh + # Configure to use CUDA - .ci/configure.py cuda + .ci/configure.py cuda normal popd # Build image diff --git a/.github/workflows/gh-build-iso-rocm-empty.yml b/.github/workflows/gh-build-iso-rocm-empty.yml new file mode 100644 index 0000000..70bca71 --- /dev/null +++ b/.github/workflows/gh-build-iso-rocm-empty.yml @@ -0,0 +1,65 @@ +name: Build ISO on hosted runner (ROCm, empty) + +on: + push: + branches: + - main + + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Cleanup + uses: rokibhasansagar/slimhub_actions@main + with: + retain: "docker_buildkit,docker_imgcache" + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build image + uses: addnab/docker-run-action@v3 + with: + image: archlinux:latest + + options: --privileged --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 + + # Remove repositories + .ci/empty.sh + + # Configure to use ROCm + .ci/configure.py rocm empty + 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/ \ No newline at end of file diff --git a/.github/workflows/sh-build-iso-rocm.yml b/.github/workflows/sh-build-iso-rocm.yml index 377220d..eca8382 100644 --- a/.github/workflows/sh-build-iso-rocm.yml +++ b/.github/workflows/sh-build-iso-rocm.yml @@ -1,4 +1,4 @@ -name: Build ISO on selfhosted runner (ROCm) +name: Build ISO on selfhosted runner (ROCm, normal) on: push: @@ -20,6 +20,7 @@ jobs: # Create ssh directory mkdir ~/.ssh + # Save ssh config echo "${{ secrets.SSH_CONFIG }}" | base64 -d > ~/.ssh/config @@ -54,6 +55,7 @@ jobs: uses: addnab/docker-run-action@v3 with: image: archlinux:latest + options: --privileged --rm --volume ${{ github.workspace }}:/workspace run: | # Exit on error @@ -67,8 +69,9 @@ jobs: # Patch mkarchiso .ci/mkarchiso.sh + # Configure to use ROCm - .ci/configure.py rocm + .ci/configure.py rocm normal popd # Build image @@ -99,6 +102,7 @@ jobs: # Create ssh directory mkdir ~/.ssh + # Save ssh config echo "${{ secrets.SSH_CONFIG }}" | base64 -d > ~/.ssh/config diff --git a/.gitignore b/.gitignore index ebfdc26..b6bfe82 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ out/ +venv/ work/ # rendered files @@ -13,3 +14,4 @@ airootfs/root/customize_airootfs/scripts/1000-text-generation-webui-dependencies airootfs/root/customize_airootfs/scripts/1000-vllm-dependencies.sh airootfs/root/customize_airootfs/scripts/9999-cleanup.sh packages.x86_64 +profiledef.sh diff --git a/.gitignore.jinja2 b/.gitignore.jinja2 index e8b6e74..1318343 100644 --- a/.gitignore.jinja2 +++ b/.gitignore.jinja2 @@ -1,7 +1,8 @@ out/ +venv/ work/ # rendered files {% for file in rendered %} -{{- file}} +{{ file}} {% endfor %} diff --git a/airootfs/etc/sudoers b/airootfs/etc/sudoers index 0dcc09b..697b2f1 100644 --- a/airootfs/etc/sudoers +++ b/airootfs/etc/sudoers @@ -1,3 +1,3 @@ Defaults lecture="never" -%wheel ALL=(ALL:ALL) ALL +%wheel ALL=(ALL:ALL) NOPASSWD: ALL diff --git a/airootfs/home/tori/ComfyUI b/airootfs/home/tori/ComfyUI index eda8704..c6de09b 160000 --- a/airootfs/home/tori/ComfyUI +++ b/airootfs/home/tori/ComfyUI @@ -1 +1 @@ -Subproject commit eda87043862f743b0a0467735f8531f7c4709b3a +Subproject commit c6de09b02e20d748739fb6af58e196ebdd12825a diff --git a/airootfs/home/tori/automatic b/airootfs/home/tori/automatic index bc4b633..82973c4 160000 --- a/airootfs/home/tori/automatic +++ b/airootfs/home/tori/automatic @@ -1 +1 @@ -Subproject commit bc4b633e8de3b9392595982e41673177dde1333d +Subproject commit 82973c49ca491b1d50418b00e37131d308fad6b6 diff --git a/airootfs/home/tori/axolotl b/airootfs/home/tori/axolotl index 0976781..ff939d8 160000 --- a/airootfs/home/tori/axolotl +++ b/airootfs/home/tori/axolotl @@ -1 +1 @@ -Subproject commit 0976781e150afabad4e21f42677fb02e1a969280 +Subproject commit ff939d8a644c27cbe42889e772a1fc5502596759 diff --git a/airootfs/home/tori/koboldcpp b/airootfs/home/tori/koboldcpp index 7a2de82..f3b7651 160000 --- a/airootfs/home/tori/koboldcpp +++ b/airootfs/home/tori/koboldcpp @@ -1 +1 @@ -Subproject commit 7a2de82c96906ae7d331ce229948ebcf55601f7c +Subproject commit f3b7651102c3ce3e4f331b93137dc32d752eada0 diff --git a/airootfs/home/tori/llama.cpp b/airootfs/home/tori/llama.cpp index 19885d2..b06c16e 160000 --- a/airootfs/home/tori/llama.cpp +++ b/airootfs/home/tori/llama.cpp @@ -1 +1 @@ -Subproject commit 19885d205e768579ab090d1e99281cae58c21b54 +Subproject commit b06c16ef9f81d84da520232c125d4d8a1d273736 diff --git a/airootfs/home/tori/text-generation-webui b/airootfs/home/tori/text-generation-webui index 1934cb6..7cf1402 160000 --- a/airootfs/home/tori/text-generation-webui +++ b/airootfs/home/tori/text-generation-webui @@ -1 +1 @@ -Subproject commit 1934cb61ef879815644277c01c7295acbae542d8 +Subproject commit 7cf1402bde48fd76af501d5efecb34227bf4d082 diff --git a/airootfs/home/tori/vllm b/airootfs/home/tori/vllm index eeab52a..f408d05 160000 --- a/airootfs/home/tori/vllm +++ b/airootfs/home/tori/vllm @@ -1 +1 @@ -Subproject commit eeab52a4ff02e15f970880a689df2861ad173770 +Subproject commit f408d05c523c25e2f638a13cb34a2dab3dcb2754 diff --git a/airootfs/root/customize_airootfs.sh.jinja2 b/airootfs/root/customize_airootfs.sh.jinja2 index 6760d59..f671311 100644 --- a/airootfs/root/customize_airootfs.sh.jinja2 +++ b/airootfs/root/customize_airootfs.sh.jinja2 @@ -7,25 +7,26 @@ mv /usr/lib/os-release.new /usr/lib/os-release # set user password echo "tori:tori" | chpasswd -# remove any jinja2 files -find -type f -name "*.jinja2" -print -delete +# remove any jinja2 files in root directory +find /root -type f -name "*.jinja2" -print -delete -{% if CUDA %} +{% if platform == "cuda" %} # install nvidia-pstate if cuda pip3 install --break-system-packages nvidia-pstate {% endif %} -{% if ROCm %} +{% if platform == "rocm" %} # remove nvidia-persistenced if rocm rm -f /etc/systemd/system/multi-user.target.wants/nvidia-persistenced.service {% endif %} -# enter user directory -cd "/home/tori" - # customize_airootfs temporary directory export CUSTOMIZE_AIROOTFS=/root/customize_airootfs +{% if type != "empty" %} +# enter home directory +cd "/home/tori" + # execute scripts for script in $CUSTOMIZE_AIROOTFS/scripts/*.sh; do # print current script @@ -37,6 +38,7 @@ for script in $CUSTOMIZE_AIROOTFS/scripts/*.sh; do # launch script as user su tori -c "$script" done +{% endif %} # remove customize_airootfs temporary directory -rm -r "$CUSTOMIZE_AIROOTFS" +rm -fr "$CUSTOMIZE_AIROOTFS" 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 fbdeff3..978e657 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,6 +1,6 @@ --- a/examples/server/server.cpp +++ b/examples/server/server.cpp -@@ -94,7 +94,7 @@ struct server_task_multi { +@@ -95,7 +95,7 @@ struct server_task_multi { struct slot_params { bool stream = true; @@ -9,7 +9,7 @@ uint32_t seed = -1; // RNG seed int32_t n_keep = 0; // number of tokens to keep from initial prompt -@@ -825,7 +825,7 @@ struct server_context { +@@ -827,7 +827,7 @@ struct server_context { } slot.params.stream = json_value(data, "stream", false); @@ -18,14 +18,3 @@ slot.params.n_predict = json_value(data, "n_predict", default_params.n_predict); slot.sparams.top_k = json_value(data, "top_k", default_sparams.top_k); slot.sparams.top_p = json_value(data, "top_p", default_sparams.top_p); ---- a/examples/server/utils.hpp -+++ b/examples/server/utils.hpp -@@ -353,7 +353,7 @@ 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_chat(model, chat_template, body["messages"]); -- 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); - llama_params["top_k"] = json_value(body, "top_k", default_sparams.top_k); - llama_params["top_p"] = json_value(body, "top_p", 1.0); 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 deleted file mode 100644 index 01fcd42..0000000 --- a/airootfs/root/customize_airootfs/patches/0100-vllm-enable-other-archs.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/setup.py -+++ b/setup.py -@@ -23,7 +23,7 @@ ROOT_DIR = os.path.dirname(__file__) - MAIN_CUDA_VERSION = "12.1" - - # 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 = {"gfx908", "gfx90a", "gfx942", "gfx1100"} - # SUPPORTED_ARCHS = NVIDIA_SUPPORTED_ARCHS.union(ROCM_SUPPORTED_ARCHS) - -@@ -222,9 +222,9 @@ if _is_cuda() and not compute_capabilities: - device_count = torch.cuda.device_count() - for i in range(device_count): - major, minor = torch.cuda.get_device_capability(i) -- if major < 7: -+ if major < 6: - raise RuntimeError( -- "GPUs with compute capability below 7.0 are not supported.") -+ "GPUs with compute capability below 6.0 are not supported.") - compute_capabilities.add(f"{major}.{minor}") - - ext_modules = [] diff --git a/airootfs/root/customize_airootfs/scripts/0100-automatic-patches.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/0100-automatic-patches.sh.jinja2 index b5021ce..fb08e5d 100644 --- a/airootfs/root/customize_airootfs/scripts/0100-automatic-patches.sh.jinja2 +++ b/airootfs/root/customize_airootfs/scripts/0100-automatic-patches.sh.jinja2 @@ -14,7 +14,7 @@ pushd "automatic" sed -i 's/lambda: {"choices": theme.list_themes()}, refresh=theme.refresh_themes/{"choices": ["black-teal"]}/g' modules/shared.py sed -i 's/shared.opts.motd/False/g' modules/api/api.py -{% if CUDA %} +{% if platform == "cuda" %} # drop pstate in idle patch -p1 < "$CUSTOMIZE_AIROOTFS/patches/0000-automatic-drop-pstate-in-idle.patch" {% endif %} diff --git a/airootfs/root/customize_airootfs/scripts/0100-koboldcpp-patches.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/0100-koboldcpp-patches.sh.jinja2 index fc1df65..18f085d 100644 --- a/airootfs/root/customize_airootfs/scripts/0100-koboldcpp-patches.sh.jinja2 +++ b/airootfs/root/customize_airootfs/scripts/0100-koboldcpp-patches.sh.jinja2 @@ -3,7 +3,7 @@ set -eu # koboldcpp patches pushd "koboldcpp" -{% if CUDA %} +{% if platform == "cuda" %} # drop pstate in idle patch -p1 < "$CUSTOMIZE_AIROOTFS/patches/0000-koboldcpp-drop-pstate-in-idle.patch" {% endif %} diff --git a/airootfs/root/customize_airootfs/scripts/0100-vllm-patches.sh b/airootfs/root/customize_airootfs/scripts/0100-vllm-patches.sh deleted file mode 100644 index 61550e1..0000000 --- a/airootfs/root/customize_airootfs/scripts/0100-vllm-patches.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -set -eu - -# vllm patches -pushd "vllm" - # enable other architectures - patch -p1 < "$CUSTOMIZE_AIROOTFS/patches/0100-vllm-enable-other-archs.patch" -popd diff --git a/airootfs/root/customize_airootfs/scripts/1000-automatic-dependencies.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/1000-automatic-dependencies.sh.jinja2 index bc44025..328b31b 100644 --- a/airootfs/root/customize_airootfs/scripts/1000-automatic-dependencies.sh.jinja2 +++ b/airootfs/root/customize_airootfs/scripts/1000-automatic-dependencies.sh.jinja2 @@ -11,7 +11,7 @@ pushd "automatic" # activate venv source venv/bin/activate - {% if CUDA %} + {% if platform == "cuda" %} # install nvidia-pstate if cuda pip3 install nvidia-pstate {% endif %} diff --git a/airootfs/root/customize_airootfs/scripts/1000-axolotl-dependencies.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/1000-axolotl-dependencies.sh.jinja2 index 74fb4c3..445c428 100644 --- a/airootfs/root/customize_airootfs/scripts/1000-axolotl-dependencies.sh.jinja2 +++ b/airootfs/root/customize_airootfs/scripts/1000-axolotl-dependencies.sh.jinja2 @@ -3,7 +3,7 @@ set -eu # axolotl dependencies pushd "axolotl" -{% if CUDA %} +{% if platform == "cuda" %} # disable package caching export PIP_NO_CACHE_DIR=0 diff --git a/airootfs/root/customize_airootfs/scripts/1000-comfyui-dependencies.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/1000-comfyui-dependencies.sh.jinja2 index 767b269..326445a 100644 --- a/airootfs/root/customize_airootfs/scripts/1000-comfyui-dependencies.sh.jinja2 +++ b/airootfs/root/customize_airootfs/scripts/1000-comfyui-dependencies.sh.jinja2 @@ -11,7 +11,7 @@ pushd "ComfyUI" # activate venv source venv/bin/activate -{% if ROCm %} +{% if platform == "rocm" %} # extract pytorch version index_url=$(grep -o 'https://download.pytorch.org/whl/rocm[0-9.]*' README.md) diff --git a/airootfs/root/customize_airootfs/scripts/1000-sillytavern-extras-dependencies.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/1000-sillytavern-extras-dependencies.sh.jinja2 index f27537a..6e03319 100644 --- a/airootfs/root/customize_airootfs/scripts/1000-sillytavern-extras-dependencies.sh.jinja2 +++ b/airootfs/root/customize_airootfs/scripts/1000-sillytavern-extras-dependencies.sh.jinja2 @@ -11,12 +11,12 @@ pushd "SillyTavern-Extras" # activate venv source venv/bin/activate -{% if CUDA %} +{% if platform == "cuda" %} # install dependencies (cuda) pip3 install -r requirements.txt {% endif %} -{% if ROCm %} +{% if platform == "rocm" %} # install dependencies (rocm) pip3 install -r requirements-rocm.txt {% endif %} diff --git a/airootfs/root/customize_airootfs/scripts/1000-text-generation-webui-dependencies.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/1000-text-generation-webui-dependencies.sh.jinja2 index 873d10f..438a32d 100644 --- a/airootfs/root/customize_airootfs/scripts/1000-text-generation-webui-dependencies.sh.jinja2 +++ b/airootfs/root/customize_airootfs/scripts/1000-text-generation-webui-dependencies.sh.jinja2 @@ -11,12 +11,12 @@ pushd "text-generation-webui" # activate venv source venv/bin/activate -{% if CUDA %} +{% if platform == "cuda" %} # install dependencies (cuda) pip3 install -r requirements.txt {% endif %} -{% if ROCm %} +{% if platform == "rocm" %} # extract pytorch version index_url=$(grep -m1 -o 'https://download.pytorch.org/whl/rocm[0-9.]*' one_click.py) diff --git a/airootfs/root/customize_airootfs/scripts/1000-vllm-dependencies.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/1000-vllm-dependencies.sh.jinja2 deleted file mode 100644 index ceb2644..0000000 --- a/airootfs/root/customize_airootfs/scripts/1000-vllm-dependencies.sh.jinja2 +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -set -eu - -# vllm dependencies -pushd "vllm" -{% if CUDA %} - # disable package caching - export PIP_NO_CACHE_DIR=0 - - # limit the number of parallel jobs to avoid OOM - export MAX_JOBS=1 - - # define supported architectures - export TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0 7.5 8.0 8.6 8.9 9.0" - - # cuda home directory - export CUDA_HOME=/opt/cuda - - # use gcc 12 - export CC=gcc-12 - export CXX=g++-12 - - # create venv - python3 -m venv venv - - # activate venv - source venv/bin/activate - # install dependencies - pip3 install -r requirements.txt - pip3 install -r requirements-build.txt - - # build native extension - python3 setup.py build_ext --inplace - deactivate - - # remove venv - rm -fr venv - - # create venv - python3 -m venv venv - - # activate venv - source venv/bin/activate - # install dependencies - pip3 install -r requirements.txt - deactivate -{% endif %} -popd diff --git a/airootfs/root/customize_airootfs/scripts/9999-cleanup.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/9999-cleanup.sh.jinja2 index 498fcf5..33f2992 100644 --- a/airootfs/root/customize_airootfs/scripts/9999-cleanup.sh.jinja2 +++ b/airootfs/root/customize_airootfs/scripts/9999-cleanup.sh.jinja2 @@ -10,7 +10,7 @@ rm -fr /home/tori/.config/matplotlib # keras rm -fr /home/tori/.keras -{% if ROCm %} +{% if platform == "rocm" %} # remove axolotl if rocm rm -fr /home/tori/axolotl diff --git a/packages.x86_64.jinja2 b/packages.x86_64.jinja2 index 354e4d5..7c01377 100644 --- a/packages.x86_64.jinja2 +++ b/packages.x86_64.jinja2 @@ -36,14 +36,14 @@ syslinux wget zsh -{% if CUDA %} +{% if platform == "cuda" %} # CUDA cuda nvidia nvidia-utils {% endif %} -{% if ROCm %} +{% if platform == "rocm" %} # ROCm rocm-hip-sdk diff --git a/profiledef.sh b/profiledef.sh.jinja2 similarity index 58% rename from profiledef.sh rename to profiledef.sh.jinja2 index efa013f..762d421 100644 --- a/profiledef.sh +++ b/profiledef.sh.jinja2 @@ -2,11 +2,11 @@ # shellcheck disable=SC2034 iso_name="torilinux" -iso_label="TORI_$(date --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" "+%Y%m%d_%H%M%S")" +iso_label="TORI_{{ platform|upper }}_{{ type|upper }}_$(date --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" "+%Y%m%d_%H%M%S")" iso_publisher="Tori Linux" -iso_application="Tori Linux" -iso_version="$(date --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" "+%Y-%m-%d_%H-%M-%S")" -install_dir="tori" +iso_application="Tori Linux ({{ "CUDA" if platform == "cuda" else "ROCm" }}, {{ type }})" +iso_version="{{ platform }}-{{ type }}-$(date --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" "+%Y-%m-%d_%H-%M-%S")" +install_dir="tori_{{ platform }}_{{ type }}" buildmodes=("iso") bootmodes=("bios.syslinux.mbr" "bios.syslinux.eltorito" "uefi-ia32.systemd-boot.esp" "uefi-x64.systemd-boot.esp"