summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: ad3903aa42968e3a3697ee87da42206838439571 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# Maintainer: robertfoster
pkgbase="local-ai"
_pkgname=LocalAI
pkgname=(
  "${pkgbase}"
  "${pkgbase}-cublas"
  "${pkgbase}-clblas"
  "${pkgbase}-hipblas"
  "${pkgbase}-sycl-f16"
  "${pkgbase}-sycl-f32"
)
pkgver=2.22.1
pkgrel=1
pkgdesc="Free, Open Source OpenAI alternative. Self-hosted, community-driven and local-first"
arch=('x86_64')
url="https://github.com/mudler/LocalAI"
license=('MIT')
backup=("etc/${pkgbase}/${pkgbase}.conf")
depends=('glibc')
conflicts=("${pkgbase}")
provides=("${pkgbase}")
options=('!strip')
makedepends=(
  'c-ares'
  'clblast'
  'cmake'
  'cuda'
  'git'
  'go'
  'grpc'
  'intel-oneapi-basekit'
  'make'
  'openblas'
  'openmpi'
  'openssl'
  're2'
  'rocm-hip-sdk'
  'upx'
)
source=("${pkgbase}-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz"
  "${pkgbase}.conf"
  "${pkgbase}.tmpfiles"
  "${pkgbase}.sysusers"
  "${pkgbase}.service"
)

prepare() {
  cd "${srcdir}/${_pkgname}-${pkgver}"
  make get-sources

  for _pkg in "${pkgname[@]}"; do
    if [ ! -d "${srcdir}/${_pkg}" ]; then
      cp -r "${srcdir}/${_pkgname}-${pkgver}" "${srcdir}/${_pkg}"
    fi
  done
}

build() {
  export GO_TAGS="tinydream"

  echo "Build ${pkgbase} with OPENBlas"
  cd "${srcdir}/${pkgbase}"
  BUILD_TYPE=openblas make build -j"$(nproc)"

  echo "Build ${pkgbase} with OpenCL"
  cd "${srcdir}/${pkgbase}-clblas"
  BUILD_TYPE=clblas make build -j"$(nproc)"

  echo "Build ${pkgbase} with CUBlas (NVIDIA CUDA)"
  cd "${srcdir}/${pkgbase}-cublas"
  export CUDA_HOME="/opt/cuda"
  export PATH="$CUDA_HOME/bin:$PATH"
  BUILD_TYPE=cublas CUDA_LIBPATH=/opt/cuda/targets/x86_64-linux/lib \
    make build -j"$(nproc)"

  echo "Build ${pkgbase} with HIPBlas (AMD ROCm)"
  cd "${srcdir}/${pkgbase}-hipblas"
  export CXXFLAGS+="$CXXFLAGS -fcf-protection=none"
  BUILD_TYPE=hipblas make build -j"$(nproc)"

  echo "Build ${pkgbase} with Intel SYCL (f16)"
  source /opt/intel/oneapi/setvars.sh
  cd "${srcdir}/${pkgbase}-sycl-f16"
  BUILD_TYPE=sycl_f16 make build -j"$(nproc)"

  echo "Build ${pkgbase} with Intel SYCL (f32)"
  source /opt/intel/oneapi/setvars.sh
  cd "${srcdir}/${pkgbase}-sycl-f32"
  BUILD_TYPE=sycl_f32 make build -j"$(nproc)"
}

_package() {
  install -Dm775 "${pkgbase}" -t "${pkgdir}/usr/bin/"

  install -D -m644 "${srcdir}/${pkgbase}.conf" \
    "${pkgdir}/etc/${pkgbase}/${pkgbase}.conf"

  upx "${pkgdir}/usr/bin/${pkgbase}"

  # systemd
  install -D -m644 "${srcdir}/${pkgbase}.service" \
    -t "${pkgdir}/usr/lib/systemd/system"
  install -D -m644 "${srcdir}/${pkgbase}.sysusers" \
    "${pkgdir}/usr/lib/sysusers.d/${pkgbase}.conf"
  install -D -m644 "${srcdir}/${pkgbase}.tmpfiles" \
    "${pkgdir}/usr/lib/tmpfiles.d/${pkgbase}.conf"
}

package_local-ai() {
  pkgdesc="$pkgdesc (with OPENBlas CPU optimizations)"
  depends+=('openblas')
  provides=("${pkgbase}=${pkgver}")
  cd "${srcdir}/${pkgbase}"
  _package
}

package_local-ai-clblas() {
  pkgdesc="$pkgdesc (with OpenCL optimizations)"
  depends+=('clblast')
  provides=("${pkgbase}=${pkgver}")
  conflicts=("${pkgbase}")

  cd "${srcdir}/${pkgbase}-clblas"
  _package
}

package_local-ai-cublas() {
  pkgdesc="$pkgdesc (with NVIDIA CUDA optimizations)"
  depends+=('cuda')
  provides=("${pkgbase}=${pkgver}")
  conflicts=("${pkgbase}")

  cd "${srcdir}/${pkgbase}-cublas"
  _package
}

package_local-ai-hipblas() {
  pkgdesc="$pkgdesc (with AMD ROCm optimizations)"
  depends+=('rocm-hip-runtime')
  provides=("${pkgbase}=${pkgver}")
  conflicts=("${pkgbase}")

  cd "${srcdir}/${pkgbase}-hipblas"
  _package
}

package_local-ai-sycl-f16() {
  pkgdesc="$pkgdesc (with Intel SYCL GPU optimizations and F16)"
  depends+=('intel-oneapi-basekit')
  provides=("${pkgbase}=${pkgver}")
  conflicts=("${pkgbase}")

  cd "${srcdir}/${pkgbase}-sycl-f16"
  _package
}

package_local-ai-sycl-f32() {
  pkgdesc="$pkgdesc (with Intel SYCL GPU optimizations and F32)"
  depends+=('intel-oneapi-basekit')
  provides=("${pkgbase}=${pkgver}")
  conflicts=("${pkgbase}")

  cd "${srcdir}/${pkgbase}-sycl-f32"
  _package
}

sha256sums=('154c32325bd1edf5fc08fdcd85c337ab6615393e2834c896fb27dbeb13e52322'
  '095c6f530c0c2f864d7aa1c22b88e111b1adc54c85e3510156dcc5b6675de00c'
  '90e042d0f5885b63a6aa4db7f87d6b931956f6c9b022407593466f61f6973312'
  '97ba21355c50ec658e220bc0558f506227b3dc77cc51f343b6f5657b0d77a19b'
  'bd420ec530cbfdb7f29b309e3c0c8cd72de6346b7c8e9882e917a071c65b344c')