commit: d0c98d31d827335e76ca9d7acf914bc57b9ec4cd Author: James McGeehan IV <bivsk <AT> tutanota <DOT> com> AuthorDate: Thu Feb 13 08:56:51 2025 +0000 Commit: James McGeehan <bivsk <AT> tutanota <DOT> com> CommitDate: Thu Feb 13 09:03:40 2025 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=d0c98d31
app-misc/ollama: install systemd service file The ollama documentation refers to a systemd service file to start the service here: https://github.com/ollama/ollama/blob/main/docs/linux.md Signed-off-by: James McGeehan IV <bivsk <AT> tutanota.com> app-misc/ollama/files/ollama.service | 14 ++++++++ app-misc/ollama/ollama-0.5.7-r1.ebuild | 28 ++++++++------- app-misc/ollama/ollama-9999.ebuild | 64 +++++++++++++++++++--------------- 3 files changed, 65 insertions(+), 41 deletions(-) diff --git a/app-misc/ollama/files/ollama.service b/app-misc/ollama/files/ollama.service new file mode 100644 index 000000000..9deee1da0 --- /dev/null +++ b/app-misc/ollama/files/ollama.service @@ -0,0 +1,14 @@ +[Unit] +Description=Ollama Service +After=network-online.target + +[Service] +ExecStart=/usr/bin/ollama serve +User=ollama +Group=ollama +Restart=always +RestartSec=3 +Environment="PATH=$PATH" + +[Install] +WantedBy=default.target diff --git a/app-misc/ollama/ollama-0.5.7-r1.ebuild b/app-misc/ollama/ollama-0.5.7-r1.ebuild index 120a9b5ff..7146a2fda 100644 --- a/app-misc/ollama/ollama-0.5.7-r1.ebuild +++ b/app-misc/ollama/ollama-0.5.7-r1.ebuild @@ -5,7 +5,7 @@ EAPI=8 ROCM_VERSION=6.1 inherit cuda rocm -inherit go-module +inherit go-module systemd DESCRIPTION="Get up and running with Llama 3, Mistral, Gemma, and other language models." HOMEPAGE="https://ollama.com" @@ -32,7 +32,7 @@ X86_CPU_FLAGS=( avx512_vnni avx512_bf16 ) -CPU_FLAGS=( "${X86_CPU_FLAGS[@]/#/cpu_flags_x86_}" ) +CPU_FLAGS=("${X86_CPU_FLAGS[@]/#/cpu_flags_x86_}") IUSE="${CPU_FLAGS[*]} cuda rocm" REQUIRED_USE=" @@ -91,17 +91,20 @@ src_prepare() { src_configure() { local CUSTOM_CPU_FLAGS=() - use cpu_flags_x86_avx && CUSTOM_CPU_FLAGS+=( "avx" ) - use cpu_flags_x86_avx2 && CUSTOM_CPU_FLAGS+=( "avx2" ) - use cpu_flags_x86_avx512f && CUSTOM_CPU_FLAGS+=( "avx512" ) - use cpu_flags_x86_avx512vbmi && CUSTOM_CPU_FLAGS+=( "avx512vbmi" ) - use cpu_flags_x86_avx512_vnni && CUSTOM_CPU_FLAGS+=( "avx512vnni" ) - use cpu_flags_x86_avx512_bf16 && CUSTOM_CPU_FLAGS+=( "avx512bf16" ) + use cpu_flags_x86_avx && CUSTOM_CPU_FLAGS+=("avx") + use cpu_flags_x86_avx2 && CUSTOM_CPU_FLAGS+=("avx2") + use cpu_flags_x86_avx512f && CUSTOM_CPU_FLAGS+=("avx512") + use cpu_flags_x86_avx512vbmi && CUSTOM_CPU_FLAGS+=("avx512vbmi") + use cpu_flags_x86_avx512_vnni && CUSTOM_CPU_FLAGS+=("avx512vnni") + use cpu_flags_x86_avx512_bf16 && CUSTOM_CPU_FLAGS+=("avx512bf16") # Build basic ollama executable with cpu features built in emakeargs=( # CCACHE="" - "CUSTOM_CPU_FLAGS=$( IFS=','; echo "${CUSTOM_CPU_FLAGS[*]}")" + "CUSTOM_CPU_FLAGS=$( + IFS=',' + echo "${CUSTOM_CPU_FLAGS[*]}" + )" ) if use cuda; then @@ -130,7 +133,7 @@ src_configure() { cuda_add_sandbox -w else - emakeargs+=( OLLAMA_SKIP_CUDA_GENERATE="1" ) + emakeargs+=(OLLAMA_SKIP_CUDA_GENERATE="1") fi if use rocm; then @@ -141,7 +144,7 @@ src_configure() { check_amdgpu else - emakeargs+=( OLLAMA_SKIP_ROCM_GENERATE="1" ) + emakeargs+=(OLLAMA_SKIP_ROCM_GENERATE="1") fi emake "${emakeargs[@]}" help-runners @@ -155,7 +158,7 @@ src_compile() { src_install() { dobin "dist/linux-${ARCH}/bin/ollama" - if [[ -d "dist/linux-${ARCH}/lib/ollama" ]] ; then + if [[ -d "dist/linux-${ARCH}/lib/ollama" ]]; then insinto /usr/lib doins -r "dist/linux-${ARCH}/lib/ollama" fi @@ -165,6 +168,7 @@ src_install() { fi doinitd "${FILESDIR}"/ollama.init + systemd_dounit "${FILESDIR}"/ollama.service } pkg_preinst() { diff --git a/app-misc/ollama/ollama-9999.ebuild b/app-misc/ollama/ollama-9999.ebuild index 79153a59f..54746c5fb 100644 --- a/app-misc/ollama/ollama-9999.ebuild +++ b/app-misc/ollama/ollama-9999.ebuild @@ -6,7 +6,7 @@ EAPI=8 ROCM_VERSION=6.1 inherit cuda rocm inherit cmake -inherit go-module toolchain-funcs +inherit go-module systemd toolchain-funcs DESCRIPTION="Get up and running with Llama 3, Mistral, Gemma, and other language models." HOMEPAGE="https://ollama.com" @@ -34,7 +34,7 @@ X86_CPU_FLAGS=( amx_tile amx_int8 ) -CPU_FLAGS=( "${X86_CPU_FLAGS[@]/#/cpu_flags_x86_}" ) +CPU_FLAGS=("${X86_CPU_FLAGS[@]/#/cpu_flags_x86_}") IUSE="${CPU_FLAGS[*]} cuda blas mkl rocm" # IUSE+=" opencl vulkan" @@ -91,53 +91,58 @@ src_prepare() { fi if ! use cpu_flags_x86_avx || - ! use cpu_flags_x86_f16c || - ! use cpu_flags_x86_avx2 || - ! use cpu_flags_x86_fma3; then + ! use cpu_flags_x86_f16c || + ! use cpu_flags_x86_avx2 || + ! use cpu_flags_x86_fma3 + then sed -e "/ggml_add_cpu_backend_variant(haswell/s/^/# /g" -i ml/backend/ggml/ggml/src/CMakeLists.txt || die # AVX F16C AVX2 FMA) fi if ! use cpu_flags_x86_avx || - ! use cpu_flags_x86_f16c || - ! use cpu_flags_x86_avx2 || - ! use cpu_flags_x86_fma3 || - ! use cpu_flags_x86_avx512f; then - sed -e "/ggml_add_cpu_backend_variant(skylakex/s/^/# /g" -i ml/backend/ggml/ggml/src/CMakeLists.txt || die + ! use cpu_flags_x86_f16c || + ! use cpu_flags_x86_avx2 || + ! use cpu_flags_x86_fma3 || + ! use cpu_flags_x86_avx512f + then + sed -e "/ggml_add_cpu_backend_variant(skylakex/s/^/# /g" -i ml/backend/ggml/ggml/src/CMakeLists.txt || die # AVX F16C AVX2 FMA AVX512) fi if ! use cpu_flags_x86_avx || - ! use cpu_flags_x86_f16c || - ! use cpu_flags_x86_avx2 || - ! use cpu_flags_x86_fma3 || - ! use cpu_flags_x86_avx512f || - ! use cpu_flags_x86_avx512vbmi || - ! use cpu_flags_x86_avx512_vnni; then + ! use cpu_flags_x86_f16c || + ! use cpu_flags_x86_avx2 || + ! use cpu_flags_x86_fma3 || + ! use cpu_flags_x86_avx512f || + ! use cpu_flags_x86_avx512vbmi || + ! use cpu_flags_x86_avx512_vnni + then sed -e "/ggml_add_cpu_backend_variant(icelake/s/^/# /g" -i ml/backend/ggml/ggml/src/CMakeLists.txt || die # AVX F16C AVX2 FMA AVX512 AVX512_VBMI AVX512_VNNI) fi if ! use cpu_flags_x86_avx || - ! use cpu_flags_x86_f16c || - ! use cpu_flags_x86_avx2 || - ! use cpu_flags_x86_fma3 || - ! use cpu_flags_x86_avx_vnni; then + ! use cpu_flags_x86_f16c || + ! use cpu_flags_x86_avx2 || + ! use cpu_flags_x86_fma3 || + ! use cpu_flags_x86_avx_vnni + then sed -e "/ggml_add_cpu_backend_variant(alderlake/s/^/# /g" -i ml/backend/ggml/ggml/src/CMakeLists.txt || die # AVX F16C AVX2 FMA AVX_VNNI) fi if ! use cpu_flags_x86_avx || - ! use cpu_flags_x86_f16c || - ! use cpu_flags_x86_avx2 || - ! use cpu_flags_x86_fma3 || - ! use cpu_flags_x86_avx512f || - ! use cpu_flags_x86_avx512vbmi || - ! use cpu_flags_x86_avx512_vnni || - ! use cpu_flags_x86_avx512_bf16 || - ! use cpu_flags_x86_amx_tile || - ! use cpu_flags_x86_amx_int8 ; then + ! use cpu_flags_x86_f16c || + ! use cpu_flags_x86_avx2 || + ! use cpu_flags_x86_fma3 || + ! use cpu_flags_x86_avx512f || + ! use cpu_flags_x86_avx512vbmi || + ! use cpu_flags_x86_avx512_vnni || + ! use cpu_flags_x86_avx512_bf16 || + ! use cpu_flags_x86_amx_tile || + ! use cpu_flags_x86_amx_int8 + then sed -e "/ggml_add_cpu_backend_variant(sapphirerapids/s/^/# /g" -i ml/backend/ggml/ggml/src/CMakeLists.txt || die #AVX F16C AVX2 FMA AVX512 AVX512_VBMI AVX512_VNNI AVX512_BF16 AMX_TILE AMX_INT8) fi @@ -271,6 +276,7 @@ src_install() { fi doinitd "${FILESDIR}"/ollama.init + systemd_dounit "${FILESDIR}"/ollama.service } pkg_preinst() {
