@@ -15,10 +15,6 @@ Python 3.10"
15
15
echo " python3"
16
16
}
17
17
18
- available () {
19
- command -v " $1 " > /dev/null
20
- }
21
-
22
18
dnf_install_intel_gpu () {
23
19
local intel_rpms=(" intel-oneapi-mkl-sycl-devel" " intel-oneapi-dnnl-devel"
24
20
" intel-oneapi-compiler-dpcpp-cpp" " intel-level-zero"
@@ -75,26 +71,6 @@ dnf_install_s390() {
75
71
dnf install -y " openblas-devel"
76
72
}
77
73
78
- add_stream_repo () {
79
- local url=" https://mirror.stream.centos.org/9-stream/$1 /$uname_m /os/"
80
- dnf config-manager --add-repo " $url "
81
- url=" http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-Official"
82
- local file=" /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official"
83
- if [ ! -e $file ]; then
84
- curl --retry 8 --retry-all-errors -o $file " $url "
85
- rpm --import $file
86
- fi
87
- }
88
-
89
- rm_non_ubi_repos () {
90
- local dir=" /etc/yum.repos.d"
91
- rm -rf $dir /mirror.stream.centos.org_9-stream_* $dir /epel*
92
- }
93
-
94
- is_rhel_based () { # doesn't include openEuler
95
- [[ " ${ID} " == " rhel" || " ${ID} " == " redhat" || " ${ID} " == " centos" ]]
96
- }
97
-
98
74
dnf_install_mesa () {
99
75
if [ " ${ID} " = " fedora" ]; then
100
76
dnf copr enable -y slp/mesa-libkrun-vulkan
@@ -110,13 +86,6 @@ dnf_install_mesa() {
110
86
rm_non_ubi_repos
111
87
}
112
88
113
- dnf_install_epel () {
114
- local rpm_exclude_list=" selinux-policy,container-selinux"
115
- local url=" https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm"
116
- dnf reinstall -y " $url " || dnf install -y " $url " --exclude " ${rpm_exclude_list} "
117
- crb enable # this is in epel-release, can only install epel-release via url
118
- }
119
-
120
89
# There is no ffmpeg-free package in the openEuler repository. openEuler can use ffmpeg,
121
90
# which also has the same GPL/LGPL license as ffmpeg-free.
122
91
dnf_install_ffmpeg () {
@@ -132,6 +101,7 @@ dnf_install_ffmpeg() {
132
101
else
133
102
dnf install -y ffmpeg-free
134
103
fi
104
+
135
105
rm_non_ubi_repos
136
106
}
137
107
@@ -258,10 +228,7 @@ clone_and_build_whisper_cpp() {
258
228
whisper_flags+=(" -DCMAKE_POSITION_INDEPENDENT_CODE=ON" )
259
229
fi
260
230
261
- git clone https://github.com/ggerganov/whisper.cpp
262
- cd whisper.cpp
263
- git submodule update --init --recursive
264
- git reset --hard " $whisper_cpp_sha "
231
+ git_clone_specific_commit " https://github.com/ggerganov/whisper.cpp" " $whisper_cpp_sha "
265
232
cmake_steps " ${whisper_flags[@]} "
266
233
mkdir -p " $install_prefix /bin"
267
234
cd ..
@@ -272,10 +239,7 @@ clone_and_build_llama_cpp() {
272
239
local llama_cpp_sha=" 3f4fc97f1d745f1d5d3c853949503136d419e6de"
273
240
local install_prefix
274
241
install_prefix=$( set_install_prefix)
275
- git clone https://github.com/ggml-org/llama.cpp
276
- cd llama.cpp
277
- git submodule update --init --recursive
278
- git reset --hard " $llama_cpp_sha "
242
+ git_clone_specific_commit " https://github.com/ggml-org/llama.cpp" " $llama_cpp_sha "
279
243
cmake_steps " ${common_flags[@]} "
280
244
install -m 755 build/bin/rpc-server " $install_prefix " /bin/rpc-server
281
245
cd ..
@@ -301,6 +265,27 @@ install_entrypoints() {
301
265
fi
302
266
}
303
267
268
+ cleanup () {
269
+ clone_and_build_llama_cpp
270
+ available dnf && dnf_remove
271
+ rm -rf /var/cache/* dnf* /opt/rocm-* /lib/* /library/* gfx9*
272
+ ldconfig # needed for libraries
273
+ }
274
+
275
+ add_common_flags () {
276
+ common_flags+=(" -DLLAMA_CURL=ON" " -DGGML_RPC=ON" )
277
+ case " $containerfile " in
278
+ ramalama)
279
+ if [ " $uname_m " = " x86_64" ] || [ " $uname_m " = " aarch64" ]; then
280
+ common_flags+=(" -DGGML_VULKAN=ON" )
281
+ elif [ " $uname_m " = " s390x" ]; then
282
+ common_flags+=(" -DGGML_VXE=ON" " -DGGML_BLAS=ON" )
283
+ common_flags+=(" -DGGML_BLAS_VENDOR=OpenBLAS" )
284
+ fi
285
+ ;;
286
+ esac
287
+ }
288
+
304
289
main () {
305
290
# shellcheck disable=SC1091
306
291
source /etc/os-release
@@ -309,6 +294,9 @@ main() {
309
294
export PYTHON
310
295
PYTHON=$( python_version)
311
296
297
+ # shellcheck disable=SC1091
298
+ source container-images/scripts/lib.sh
299
+
312
300
local containerfile=${1-" " }
313
301
local install_prefix
314
302
install_prefix=$( set_install_prefix)
@@ -321,27 +309,15 @@ main() {
321
309
if [ -n " $containerfile " ]; then
322
310
install_ramalama " ${install_prefix} "
323
311
fi
324
- install_entrypoints
325
312
313
+ install_entrypoints
326
314
setup_build_env
327
315
if [ " $uname_m " != " s390x" ] && [ " $containerfile " != " rocm-ubi" ]; then
328
316
clone_and_build_whisper_cpp
329
317
fi
330
- common_flags+=(" -DLLAMA_CURL=ON" " -DGGML_RPC=ON" )
331
- case " $containerfile " in
332
- ramalama)
333
- if [ " $uname_m " = " x86_64" ] || [ " $uname_m " = " aarch64" ]; then
334
- common_flags+=(" -DGGML_VULKAN=ON" )
335
- elif [ " $uname_m " = " s390x" ]; then
336
- common_flags+=(" -DGGML_VXE=ON" " -DGGML_BLAS=ON" " -DGGML_BLAS_VENDOR=OpenBLAS" )
337
- fi
338
- ;;
339
- esac
340
318
341
- clone_and_build_llama_cpp
342
- available dnf && dnf_remove
343
- rm -rf /var/cache/* dnf* /opt/rocm-* /lib/* /library/* gfx9*
344
- ldconfig # needed for libraries
319
+ add_common_flags
320
+ cleanup
345
321
}
346
322
347
323
main " $@ "
0 commit comments