git: ee1259996679 - main - misc/ollama: Improve pkg-message

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Mon, 19 Aug 2024 01:12:11 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=ee1259996679f14ac8b59a10d10614d840d89460

commit ee1259996679f14ac8b59a10d10614d840d89460
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2024-08-19 01:11:36 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2024-08-19 01:12:09 +0000

    misc/ollama: Improve pkg-message
---
 misc/ollama/Makefile                                               | 5 +++--
 misc/ollama/files/{ollama-limit-layers => ollama-limit-gpu-layers} | 2 ++
 misc/ollama/pkg-message                                            | 6 +++++-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/misc/ollama/Makefile b/misc/ollama/Makefile
index be457b2db084..724bc72feceb 100644
--- a/misc/ollama/Makefile
+++ b/misc/ollama/Makefile
@@ -1,6 +1,7 @@
 PORTNAME=	ollama
 DISTVERSIONPREFIX=	v
 DISTVERSION=	0.3.6
+PORTREVISION=	1
 CATEGORIES=	misc # machine-learning
 
 MAINTAINER=	yuri@FreeBSD.org
@@ -33,7 +34,7 @@ GH_TUPLE=	ggerganov:llama.cpp:1e6f6554aa11fa10160a5fda689e736c3c34169f:llama_cpp
 MAKE_ENV=	PATH=${PATH}:${WRKSRC}/llm/build/bsd/x86_64_static/bin # workaround to find vulkan-shaders-gen
 
 PLIST_FILES=	bin/${PORTNAME} \
-		bin/ollama-limit-layers
+		bin/ollama-limit-gpu-layers
 
 post-patch: # workaround for https://github.com/ollama/ollama/issues/6259 (use of extenral libllama.so)
 	@${REINPLACE_CMD} \
@@ -53,6 +54,6 @@ pre-build:
 			./...
 
 post-install: # pending https://github.com/ollama/ollama/issues/6407
-	${INSTALL_SCRIPT} ${FILESDIR}/ollama-limit-layers ${STAGEDIR}${PREFIX}/bin
+	${INSTALL_SCRIPT} ${FILESDIR}/ollama-limit-gpu-layers ${STAGEDIR}${PREFIX}/bin
 
 .include <bsd.port.mk>
diff --git a/misc/ollama/files/ollama-limit-layers b/misc/ollama/files/ollama-limit-gpu-layers
similarity index 93%
rename from misc/ollama/files/ollama-limit-layers
rename to misc/ollama/files/ollama-limit-gpu-layers
index 6713a9f9b02b..f17cb5622d0b 100755
--- a/misc/ollama/files/ollama-limit-layers
+++ b/misc/ollama/files/ollama-limit-gpu-layers
@@ -5,9 +5,11 @@ NUM_GPU=$2
 
 if [ -z "$MODEL" ] || [ -z "$NUM_GPU" ]; then
 	echo "Usage: $0 <model> <num_gpu>"
+	exit 1
 fi
 
 ollama show --modelfile $MODEL > Modelfile &&
 echo "PARAMETER num_gpu $NUM_GPU" >> Modelfile &&
 ollama create "$MODEL-num_gpu$NUM_GPU" -f Modelfile &&
+rm Modelfile &&
 echo "model variant $MODEL-num_gpu$NUM_GPU was created"
diff --git a/misc/ollama/pkg-message b/misc/ollama/pkg-message
index 95b0d4e58448..936a3494000a 100644
--- a/misc/ollama/pkg-message
+++ b/misc/ollama/pkg-message
@@ -12,6 +12,10 @@ To run ollama, plese open 2 terminals.
 This will download and run the AI model "mistral".
 You will be able to interact with it in plain English.
 
+If the above fails, you can try to run 'ollama start'
+with theenvironment variable OLLAMA_NUM_PARALLEL=1.
+This is known to help with smaller models.
+
 Please see https://ollama.com/library for the list
 of all supported models.
 
@@ -19,7 +23,7 @@ The command "ollama list" lists all models downloaded
 into your system.
 
 When the model fails to load into your GPU, please use
-the provided ollama-limit-layers script to create
+the provided ollama-limit-gpu-layers script to create
 model flavors with different num_gpu parameters.
 
 ollama uses many gigbytes of disk space in your home directory,