summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: ea7561066148341d63150998579e3e2b4ddda917 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Maintainer: Orion-zhen <https://github.com/Orion-zhen>

pkgname=ik-llama.cpp-cuda
_pkgname=ik_llama.cpp
pkgver=r3913.2f951a8a
pkgrel=1
pkgdesc="llama.cpp fork with additional SOTA quants and improved performance (CUDA Backend)"
arch=(x86_64 armv7h aarch64)
url="https://github.com/ikawrakow/ik_llama.cpp"
license=("MIT")
depends=(
    cuda
    nvidia-utils
    curl
    gcc-libs
    glibc
    python
)
makedepends=(
    cmake
    git
)
optdepends=(
    'python-numpy: needed for convert_hf_to_gguf.py'
    'python-safetensors: needed for convert_hf_to_gguf.py'
    'python-sentencepiece: needed for convert_hf_to_gguf.py'
    'python-pytorch: needed for convert_hf_to_gguf.py'
    'python-transformers: needed for convert_hf_to_gguf.py'
)
conflicts=(
    libggml
    ggml
    llama.cpp
    llama.cpp-vulkan
    llama.cpp-cuda
    llama.cpp-hip
    ik-llama.cpp
    ik-llama.cpp-vulkan
)
provides=(llama.cpp)

options=(lto !debug)

source=()
sha256sums=()

prepare() {
    cd "$srcdir"
    git clone --single-branch --branch main "${url}" "${_pkgname}"
}

pkgver() {
    cd "$_pkgname"
    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
    if [[ -z "${NVCC_CCBIN}" ]]; then
        source /etc/profile
    fi

    local _cmake_options=(
        -B build
        -S "${_pkgname}"
        -DCMAKE_INSTALL_PREFIX='/usr'
        -DBUILD_SHARED_LIBS=ON
        -DLLAMA_CURL=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_CUDA=ON
        -DGGML_LTO=ON
        -DGGML_RPC=ON
        -Wno-dev
    )

    # 检查是否在 CI 环境中构建
    if [ -n "$CI" ] && [ "$CI" != 0 ]; then
        msg2 "CI = $CI detected, building universal package"
        # 启用通用构建
        _cmake_options+=(
        -DGGML_BACKEND_DL=ON
        -DGGML_CPU_ALL_VARIANTS=ON
        -DGGML_NATIVE=OFF
        )
    else
        # 本地构建, 针对当前设备优化
        _cmake_options+=(
        -DGGML_NATIVE=ON
        )
    fi


    cmake "${_cmake_options[@]}"
    cmake --build build --config Release -- -j $(nproc)
}

package() {
    DESTDIR="${pkgdir}" cmake --install build
}