# Maintainer: bsdice _commit="" #_commit="#commit=312cf03328496df9c56fe843952cf02a8964c59a" pkgname=llama.cpp-cuda-git _pkgname="llama.cpp" pkgver=b8548.r5.20197b6fe3 pkgrel=1 pkgdesc="Port of Facebook's LLaMA model in C/C++ (with NVIDIA CUDA optimizations)" arch=(x86_64 aarch64) url='https://github.com/ggerganov/llama.cpp' depends=(cuda curl gcc-libs glibc nvidia-utils) makedepends=(cmake git openssl cudnn) conflicts=("${_pkgname}" libggml ggml) provides=("${_pkgname}") replaces=("${_pkgname}") backup=(etc/conf.d/llama.cpp) install=llama.cpp.install license=('MIT') _extra_commits=( ) source=( "git+https://github.com/ggml-org/llama.cpp.git${_commit}" #"llama.cpp::git+https://github.com/spiritbuun/llama-cpp-turboquant-cuda.git#commit=7c6250688c0b3e4348ddae0a10df0307b8efb878" llama.cpp.conf llama.cpp.service llama.cpp.install ) sha256sums=(SKIP SKIP SKIP SKIP) optdepends=( 'python-sentencepiece: needed for convert_hf_to_gguf.py' 'python-transformers: needed for convert_hf_to_gguf.py' 'python-safetensors: needed for convert_hf_to_gguf.py' 'python-pytorch: needed for convert_hf_to_gguf.py' 'python-numpy: needed for convert_hf_to_gguf.py' ) pkgver() { cd "${_pkgname}" || exit 1 _ver="$(git describe --tags | sed 's/\([^-]*-\)g/r\1/;s/-/./g')" if [ -n "$_ver" ]; then printf "%s" "$_ver" else _ver2="23" printf "%s.%s" "$_ver2" "$(git rev-parse --short HEAD)" fi } prepare() { cd "${_pkgname}" || exit 1 # Apply extra commits local _c _l for _c in "${_extra_commits[@]}"; do if [[ "${_c}" == *..* ]]; then _l='--reverse'; else _l='--max-count=1'; fi git log --oneline "${_l}" "${_c}" git cherry-pick --mainline 1 --no-commit "${_c}" done # Apply patches local _src for _src in "${source[@]}"; do _src="${_src%%::*}" _src="${_src##*/}" [[ $_src = *.patch ]] || continue echo -e "\n*** Applying patch $_src..." patch --no-backup-if-mismatch -Np1 < "$srcdir/$_src" done cd .. ln -sf "${_pkgname}" llama.cpp } build() { cd "${_pkgname}" || exit 1 _commit_id=$(git rev-parse HEAD) _build_number=$(git rev-list --count HEAD) cd .. local _cmake_options=( -B build -S "${_pkgname}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX='/usr' -DBUILD_SHARED_LIBS=ON -DLLAMA_BUILD_TESTS=OFF -DLLAMA_USE_SYSTEM_GGML=OFF -DGGML_ALL_WARNINGS=OFF -DGGML_ALL_WARNINGS_3RD_PARTY=OFF -DGGML_BUILD_EXAMPLES=OFF -DGGML_BUILD_TESTS=OFF -DGGML_OPENMP=ON -DGGML_RPC=ON -DGGML_LTO=ON -DGGML_CUDA=ON -DGGML_CUDA_FA_ALL_QUANTS=ON -DGGML_CUDNN=ON -DLLAMA_BUILD_SERVER=ON -DLLAMA_BUILD_NUMBER="${_build_number}" -DLLAMA_BUILD_COMMIT="${_commit_id}" -DLLAMA_OPENSSL=ON -Wno-dev -DGGML_NATIVE=ON # -DGGML_BACKEND_DL=ON # -DGGML_NATIVE=OFF # -DGGML_CPU_ALL_VARIANTS=ON ) cmake "${_cmake_options[@]}" cmake --build build } package() { DESTDIR="${pkgdir}" cmake --install build install -Dm644 "${_pkgname}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" install -Dm644 "llama.cpp.conf" "${pkgdir}/etc/conf.d/llama.cpp" install -Dm644 "llama.cpp.service" "${pkgdir}/usr/lib/systemd/system/llama.cpp.service" }