1# SRPM for building from source and packaging an RPM for RPM-based distros.
 2# https://docs.fedoraproject.org/en-US/quick-docs/creating-rpm-packages
 3# Built and maintained by John Boero - boeroboy@gmail.com
 4# In honor of Seth Vidal https://www.redhat.com/it/blog/thank-you-seth-vidal
 5
 6# Notes for llama.cpp:
 7# 1. Tags are currently based on hash - which will not sort asciibetically.
 8#    We need to declare standard versioning if people want to sort latest releases.
 9#    In the meantime, YYYYMMDD format will be used.
10# 2. Builds for CUDA/OpenCL support are separate, with different depenedencies.
11# 3. NVidia's developer repo must be enabled with nvcc, cublas, clblas, etc installed.
12#    Example: https://developer.download.nvidia.com/compute/cuda/repos/fedora37/x86_64/cuda-fedora37.repo
13# 4. OpenCL/CLBLAST support simply requires the ICD loader and basic opencl libraries.
14#    It is up to the user to install the correct vendor-specific support.
15
16Name:           llama.cpp
17Version:        %( date "+%%Y%%m%%d" )
18Release:        1%{?dist}
19Summary:        CPU Inference of LLaMA model in pure C/C++ (no CUDA/OpenCL)
20License:        MIT
21Source0:        https://github.com/ggml-org/llama.cpp/archive/refs/heads/master.tar.gz
22BuildRequires:  coreutils make gcc-c++ git libstdc++-devel
23Requires:       libstdc++
24URL:            https://github.com/ggml-org/llama.cpp
25
26%define debug_package %{nil}
27%define source_date_epoch_from_changelog 0
28
29%description
30CPU inference for Meta's Lllama2 models using default options.
31Models are not included in this package and must be downloaded separately.
32
33%prep
34%setup -n llama.cpp-master
35
36%build
37make -j
38
39%install
40mkdir -p %{buildroot}%{_bindir}/
41cp -p llama-cli %{buildroot}%{_bindir}/llama-cli
42cp -p llama-completion %{buildroot}%{_bindir}/llama-completion
43cp -p llama-server %{buildroot}%{_bindir}/llama-server
44cp -p llama-simple %{buildroot}%{_bindir}/llama-simple
45
46mkdir -p %{buildroot}/usr/lib/systemd/system
47%{__cat} <<EOF  > %{buildroot}/usr/lib/systemd/system/llama.service
48[Unit]
49Description=Llama.cpp server, CPU only (no GPU support in this build).
50After=syslog.target network.target local-fs.target remote-fs.target nss-lookup.target
51
52[Service]
53Type=simple
54EnvironmentFile=/etc/sysconfig/llama
55ExecStart=/usr/bin/llama-server $LLAMA_ARGS
56ExecReload=/bin/kill -s HUP $MAINPID
57Restart=never
58
59[Install]
60WantedBy=default.target
61EOF
62
63mkdir -p %{buildroot}/etc/sysconfig
64%{__cat} <<EOF  > %{buildroot}/etc/sysconfig/llama
65LLAMA_ARGS="-m /opt/llama2/ggml-model-f32.bin"
66EOF
67
68%clean
69rm -rf %{buildroot}
70rm -rf %{_builddir}/*
71
72%files
73%{_bindir}/llama-cli
74%{_bindir}/llama-completion
75%{_bindir}/llama-server
76%{_bindir}/llama-simple
77/usr/lib/systemd/system/llama.service
78%config /etc/sysconfig/llama
79
80%pre
81
82%post
83
84%preun
85%postun
86
87%changelog