From b8883e254a200bafc5bb60333e26a2261c25a0b3 Mon Sep 17 00:00:00 2001 From: henk717 Date: Mon, 26 May 2025 09:24:49 +0200 Subject: [PATCH] KoboldCpp.sh updates (#1562) * YR makefile upstream * Create make_portable_rocm_libs.sh * update makefile, support llama portable, ditch all unnecessary changes * Delete make_portable_rocm_libs.sh should not be needed * koboldcpp.sh updates * Small rocm fixes * ROCm is now a cuda version not a command * Don't commit temp file * Don't commit temp file * 1200 has errors, removing it for now * Only rebuild rocm with rebuild * Update kcpp-build-release-linux.yaml * Fix rocm filename * ROCm Linux CI * We need more diskspace * Workaround for lockfile getting stuck Why do I have to do hacks like this.... * Update kcpp-build-release-linux-rocm.yaml * Dont apt update rocm You don't allow us to apt update? Better not break things github! * Container maybe? * Turns out we aren't root, so we use sudo * Cleanup ROCm CI PR * Build for Runpods GPU * We also need rocblas * More cleanup just in case * Update kcpp-build-release-linux-rocm.yaml --------- Co-authored-by: LostRuins Concedo <39025047+LostRuins@users.noreply.github.com> --- .../kcpp-build-release-linux-rocm.yaml | 72 ++++++++++++++++++ .../workflows/kcpp-build-release-linux.yaml | 1 + .gitignore | 2 + Makefile | 6 +- create_ver_file.sh | 0 environment-nocuda.yaml | 21 +++++ environment.yaml | 2 +- glslc-linux | Bin koboldcpp.sh | 39 ++++++++-- 9 files changed, 131 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/kcpp-build-release-linux-rocm.yaml mode change 100644 => 100755 create_ver_file.sh create mode 100644 environment-nocuda.yaml mode change 100644 => 100755 glslc-linux diff --git a/.github/workflows/kcpp-build-release-linux-rocm.yaml b/.github/workflows/kcpp-build-release-linux-rocm.yaml new file mode 100644 index 000000000..c5d8d473f --- /dev/null +++ b/.github/workflows/kcpp-build-release-linux-rocm.yaml @@ -0,0 +1,72 @@ +name: Koboldcpp Linux ROCm + +on: + workflow_dispatch: + inputs: + commit_hash: + description: 'Optional commit hash to build from' + required: false + default: '' + +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + KCPP_CUDA: rocm + ARCHES_CU12: 1 + +jobs: + linux: + runs-on: ubuntu-22.04 + 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@v3 + with: + ref: ${{ inputs.commit_hash != '' && inputs.commit_hash || github.head_ref || github.ref_name }} + + - name: Show Commit Used + run: | + echo "Building from ref: ${{ inputs.commit_hash != '' && inputs.commit_hash || github.head_ref || github.ref_name }}" + + - name: Dependencies + id: depends + run: | + sudo apt update + export DEBIAN_FRONTEND=noninteractive + sudo ln -fs /usr/share/zoneinfo/UTC /etc/localtime + echo "tzdata tzdata/Areas select Etc" | sudo debconf-set-selections + echo "tzdata tzdata/Zones/Etc select UTC" | sudo debconf-set-selections + sudo apt-get -y install git curl bzip2 python3-tk tcl tk + curl -fLO https://repo.radeon.com/rocm/installer/rocm-runfile-installer/rocm-rel-6.4.1/ubuntu/22.04/rocm-installer_1.1.1.60401-30-83~22.04.run && sudo bash rocm-installer_1.1.1.60401-30-83~22.04.run deps=install rocm postrocm target="/opt" + sudo rm -rf rocm-install* + + - name: Set Tcl/Tk Paths + run: | + echo "TCL_LIBRARY=$(find /usr/lib/ -name 'tcl8*' | head -n 1)" >> $GITHUB_ENV + echo "TK_LIBRARY=$(find /usr/lib/ -name 'tk8*' | head -n 1)" >> $GITHUB_ENV + + - name: Build + id: make_build + run: | + ./koboldcpp.sh dist + + - name: Save artifact + uses: actions/upload-artifact@v4 + with: + name: kcpp_linux_binary + path: dist/ diff --git a/.github/workflows/kcpp-build-release-linux.yaml b/.github/workflows/kcpp-build-release-linux.yaml index ada4246e1..7614d5050 100644 --- a/.github/workflows/kcpp-build-release-linux.yaml +++ b/.github/workflows/kcpp-build-release-linux.yaml @@ -12,6 +12,7 @@ env: BRANCH_NAME: ${{ github.head_ref || github.ref_name }} NOAVX2: 1 ARCHES_CU11: 1 + KCPP_CUDA: 11.5.0 jobs: linux: diff --git a/.gitignore b/.gitignore index f7164a968..104f71c9a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ *.o *.a *.bin +*.tmp.yaml + .DS_Store .build/ .cache/ diff --git a/Makefile b/Makefile index 179b05574..cffbb4773 100644 --- a/Makefile +++ b/Makefile @@ -243,7 +243,7 @@ ifdef LLAMA_HIPBLAS ifeq ($(wildcard /opt/rocm),) ROCM_PATH ?= /usr ifdef LLAMA_PORTABLE - GPU_TARGETS ?= gfx803 gfx900 gfx906 gfx908 gfx90a gfx1010 gfx1030 gfx1031 gfx1032 gfx1100 gfx1101 gfx1102 $(shell $(shell which amdgpu-arch)) + GPU_TARGETS ?= gfx803 gfx900 gfx906 gfx908 gfx90a gfx942 gfx1010 gfx1030 gfx1031 gfx1032 gfx1100 gfx1101 gfx1102 $(shell $(shell which amdgpu-arch)) else GPU_TARGETS ?= $(shell $(shell which amdgpu-arch)) endif @@ -251,7 +251,7 @@ endif HCXX := $(ROCM_PATH)/bin/hipcc else ROCM_PATH ?= /opt/rocm - GPU_TARGETS ?= gfx803 gfx900 gfx906 gfx908 gfx90a gfx1010 gfx1030 gfx1031 gfx1032 gfx1100 gfx1101 gfx1102 $(shell $(ROCM_PATH)/llvm/bin/amdgpu-arch) + GPU_TARGETS ?= gfx803 gfx900 gfx906 gfx908 gfx90a gfx942 gfx1010 gfx1030 gfx1031 gfx1032 gfx1100 gfx1101 gfx1102 $(shell $(ROCM_PATH)/llvm/bin/amdgpu-arch) HCC := $(ROCM_PATH)/llvm/bin/clang HCXX := $(ROCM_PATH)/llvm/bin/clang++ endif @@ -859,4 +859,4 @@ build-info.h: #phony for printing messages finishedmsg: $(NOTIFY_MSG) - $(DONOTHING) \ No newline at end of file + $(DONOTHING) diff --git a/create_ver_file.sh b/create_ver_file.sh old mode 100644 new mode 100755 diff --git a/environment-nocuda.yaml b/environment-nocuda.yaml new file mode 100644 index 000000000..4c46f772c --- /dev/null +++ b/environment-nocuda.yaml @@ -0,0 +1,21 @@ +name: koboldcpp +channels: + - conda-forge + - defaults +dependencies: + - python=3.10 + - cxx-compiler + - gxx=10 + - pip + - git=2.35.1 + - clblast + - ninja + - make + - packaging + - pyinstaller + - libcblas + - ocl-icd-system + - libvulkan-loader + - tk=*=xft_* + - pip: + - customtkinter diff --git a/environment.yaml b/environment.yaml index 89fe652d1..d7aa7adcd 100644 --- a/environment.yaml +++ b/environment.yaml @@ -1,6 +1,6 @@ name: koboldcpp channels: - - nvidia/label/cuda-11.5.0 + - nvidia/label/cuda-12.1.0 - conda-forge - defaults dependencies: diff --git a/glslc-linux b/glslc-linux old mode 100644 new mode 100755 diff --git a/koboldcpp.sh b/koboldcpp.sh index c05a15750..8b6144c20 100755 --- a/koboldcpp.sh +++ b/koboldcpp.sh @@ -4,12 +4,12 @@ if [ ! -f "bin/micromamba" ]; then curl -Ls https://anaconda.org/conda-forge/micromamba/1.5.3/download/linux-64/micromamba-1.5.3-0.tar.bz2 | tar -xvj bin/micromamba fi -if [[ ! -f "conda/envs/linux/bin/python" || $1 == "rebuild" ]]; then +if [[ ! -f "conda/envs/linux/bin/python" && $KCPP_CUDA != "rocm" || $1 == "rebuild" && $KCPP_CUDA != "rocm" ]]; then cp environment.yaml environment.tmp.yaml if [ -n "$KCPP_CUDA" ]; then - sed -i -e "s/nvidia\/label\/cuda-11.5.0/nvidia\/label\/cuda-$KCPP_CUDA/g" environment.tmp.yaml + sed -i -e "s/nvidia\/label\/cuda-12.1.0/nvidia\/label\/cuda-$KCPP_CUDA/g" environment.tmp.yaml else - KCPP_CUDA=11.5.0 + KCPP_CUDA=12.1.0 fi bin/micromamba create --no-rc --no-shortcuts -r conda -p conda/envs/linux -f environment.tmp.yaml -y bin/micromamba create --no-rc --no-shortcuts -r conda -p conda/envs/linux -f environment.tmp.yaml -y @@ -17,6 +17,13 @@ if [[ ! -f "conda/envs/linux/bin/python" || $1 == "rebuild" ]]; then echo $KCPP_CUDA > conda/envs/linux/cudaver echo rm environment.tmp.yaml fi + +if [[ ! -f "conda/envs/linux/bin/python" && $KCPP_CUDA == "rocm" || $1 == "rebuild" && $KCPP_CUDA == "rocm" ]]; then + bin/micromamba create --no-rc --no-shortcuts -r conda -p conda/envs/linux -f environment-nocuda.yaml -y + bin/micromamba run -r conda -p conda/envs/linux make clean + echo "rocm" > conda/envs/linux/cudaver +fi + KCPP_CUDA=$(