From 4c43f07b64c1e4d930ed3daa60eeebcb120f6000 Mon Sep 17 00:00:00 2001 From: shalinib-ibm Date: Tue, 19 May 2026 12:27:50 +0530 Subject: [PATCH 01/12] Create set_threads_env_v0.24.0.patch --- o/ollama/set_threads_env_v0.24.0.patch | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 o/ollama/set_threads_env_v0.24.0.patch diff --git a/o/ollama/set_threads_env_v0.24.0.patch b/o/ollama/set_threads_env_v0.24.0.patch new file mode 100644 index 0000000000..69e150cea9 --- /dev/null +++ b/o/ollama/set_threads_env_v0.24.0.patch @@ -0,0 +1,46 @@ +diff --git a/discover/gpu.go b/discover/gpu.go +index 4a7d552d..789d6c8d 100644 +--- a/discover/gpu.go ++++ b/discover/gpu.go +@@ -9,6 +9,7 @@ import ( + "strings" + "time" + ++ "github.com/ollama/ollama/envconfig" + "github.com/ollama/ollama/logutil" + "github.com/ollama/ollama/ml" + ) +@@ -40,6 +41,11 @@ func GetSystemInfo() ml.SystemInfo { + threadCount = runtime.NumCPU() + } + ++ if userThreadCount := envconfig.NumThreads(); userThreadCount > 0 { ++ slog.Info("user override thread count", "override", userThreadCount, "default", threadCount) ++ threadCount = int(userThreadCount) ++ } ++ + return ml.SystemInfo{ + ThreadCount: threadCount, + TotalMemory: memInfo.TotalMemory, +diff --git a/envconfig/config.go b/envconfig/config.go +index f4bd4aa6..b10307d1 100644 +--- a/envconfig/config.go ++++ b/envconfig/config.go +@@ -271,6 +271,8 @@ func Uint(key string, defaultValue uint) func() uint { + } + + var ( ++ // NumThreads overrides the default inference thread count. ++ NumThreads = Uint("OLLAMA_NUM_THREADS", 0) + // NumParallel sets the number of parallel model requests. NumParallel can be configured via the OLLAMA_NUM_PARALLEL environment variable. + NumParallel = Uint("OLLAMA_NUM_PARALLEL", 1) + // MaxRunners sets the maximum number of loaded models. MaxRunners can be configured via the OLLAMA_MAX_LOADED_MODELS environment variable. +@@ -324,6 +326,7 @@ func AsMap() map[string]EnvVar { + "OLLAMA_MAX_QUEUE": {"OLLAMA_MAX_QUEUE", MaxQueue(), "Maximum number of queued requests"}, + "OLLAMA_MODELS": {"OLLAMA_MODELS", Models(), "The path to the models directory"}, + "OLLAMA_NO_CLOUD": {"OLLAMA_NO_CLOUD", NoCloud(), "Disable Ollama cloud features (remote inference and web search)"}, ++ "OLLAMA_NUM_THREADS": {"OLLAMA_NUM_THREADS", NumThreads(), "Override the default cpu inference thread count"}, + "OLLAMA_NOHISTORY": {"OLLAMA_NOHISTORY", NoHistory(), "Do not preserve readline history"}, + "OLLAMA_NOPRUNE": {"OLLAMA_NOPRUNE", NoPrune(), "Do not prune model blobs on startup"}, + "OLLAMA_NUM_PARALLEL": {"OLLAMA_NUM_PARALLEL", NumParallel(), "Maximum number of parallel requests"}, + From c0eaa6f53c7dbde45906ffc912cd164ea9cdcc8e Mon Sep 17 00:00:00 2001 From: shalinib-ibm Date: Tue, 19 May 2026 12:37:41 +0530 Subject: [PATCH 02/12] Add build scripts for ollama v0.24.0 --- o/ollama/ollama_v0.24.0_ubi_9.6.sh | 194 +++++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 o/ollama/ollama_v0.24.0_ubi_9.6.sh diff --git a/o/ollama/ollama_v0.24.0_ubi_9.6.sh b/o/ollama/ollama_v0.24.0_ubi_9.6.sh new file mode 100644 index 0000000000..05acd868a5 --- /dev/null +++ b/o/ollama/ollama_v0.24.0_ubi_9.6.sh @@ -0,0 +1,194 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# +# Package : Ollama (Power10 optimized) +# Version : v0.24.0 +# Source repo : https://github.com/ollama/ollama +# Tested on : UBI:9.6 +# Language : Go, C, Python +# Ci-Check : True +# Script License : Apache License, Version 2 or later +# Maintainer : Shalini Salomi Bodapati +# +# Disclaimer: This script has been tested in root mode on given +# ========== platform using the mentioned version of the package. +# It may not work as expected with newer versions of the +# package and/or distribution. In such case, please +# contact "Maintainer" of this script. +# +# ----------------------------------------------------------------------------- + +set -e + +# Variables +PACKAGE_NAME=ollama +PACKAGE_VERSION=${1:-v0.24.0} +PACKAGE_URL=https://github.com/ollama/ollama +OLLAMA_VERSION=${PACKAGE_VERSION} +CURRENT_DIR=$(pwd) +PACKAGE_DIR=ollama +SCRIPT_PATH=$(dirname $(realpath $0)) + +echo "------------------------Installing dependencies-------------------" + +# install core dependencies +yum install -y python python-pip python-devel gcc-toolset-13 gcc-toolset-13-binutils gcc-toolset-13-binutils-devel gcc-toolset-13-gcc-c++ git make cmake binutils wget patch + +python -m pip install --upgrade pip setuptools wheel build + +export PATH=/opt/rh/gcc-toolset-13/root/usr/bin:$PATH +export LD_LIBRARY_PATH=/opt/rh/gcc-toolset-13/root/usr/lib64:$LD_LIBRARY_PATH +gcc --version + +echo "**** Checking GCC version..." +gcc -v || true + +# ----------------------------------------------------------------------------- +# Download Go +# ----------------------------------------------------------------------------- +GO_VERSION="1.26.1" +GO_TAR="go${GO_VERSION}.linux-ppc64le.tar.gz" +GO_DIR="go" + +if [ ! -d "${GO_DIR}" ]; then + echo "**** Downloading Go ${GO_VERSION}..." + wget -q https://go.dev/dl/${GO_TAR} + echo "**** Extracting Go binary..." + tar xzf ${GO_TAR} +else + echo "**** Go already extracted, skipping..." +fi + +export PATH="$(pwd)/go/bin:$PATH" + +# ----------------------------------------------------------------------------- +# Clone and patch Ollama +# ----------------------------------------------------------------------------- + +echo "**** Cloning Ollama repository..." +git clone $PACKAGE_URL +cd $PACKAGE_NAME +git checkout $PACKAGE_VERSION + +echo "** Downloading power specific patches **" +wget -q -O ppc_sync1.patch https://github.com/ollama/ollama/commit/035aee3b98e666b42fbab724aa9aaa176360844f.patch +wget -q -O ppc_sync2.patch https://github.com/ollama/ollama/commit/b765e03d192fe99e96a8008daeb76a0a843e997d.patch +wget -q -O ppc_build_fix.patch https://github.com/ollama/ollama/commit/4115e4f58f8c3fb86cdce2d58aae811c2d26cc52.patch +wget -O set_threads_env.patch https://raw.githubusercontent.com/ppc64le/build-scripts/refs/heads/master/o/ollama/set_threads_env_v0.24.0.patch + +echo "** Applying power specific patches**" +patch -p1 < ppc_sync1.patch +patch -p1 < ppc_sync2.patch +patch -p1 < ppc_build_fix.patch +patch -p1 < set_threads_env.patch + +# ----------------------------------------------------------------------------- +# Build Ollama +# ----------------------------------------------------------------------------- +echo "**** Building Ollama with CMake..." +cmake -B build +cmake --build build -j$(nproc) + + +export CGO_LDFLAGS="-L$(pwd)/build/lib/ollama -lggml-cpu-power10 -Wl,-rpath,\$ORIGIN/../lib" + +echo "**** Building Ollama binary with Go..." +../go/bin/go build --tags ppc64le.power10 -o ollama . + +if ls ollama 1>/dev/null 2>&1; then + echo "Ollama Binary built successfully:" + ls ollama +else + echo "Ollama Build failed" + EXIT_CODE=1 +fi + +# ----------------------------------------------------------------------------- +# Auto-generate setup.py and minimal package structure for wheel build +# ----------------------------------------------------------------------------- +echo "**** Creating setup.py and package files ****" + +PKG_NAME="ollama_python_package" +mkdir -p ${PKG_NAME} ${PKG_NAME}/bin ${PKG_NAME}/lib + +# Generate setup.py +cat < setup.py +from setuptools import setup, find_packages +from setuptools.command.build_py import build_py +import os, shutil, stat + +PYTHON_PACKAGE_NAME = "ollama_python_package" +VERSION = "${PACKAGE_VERSION#v}" + +BIN_SRC = os.path.join(os.getcwd(), "ollama") +LIB_SRC = os.path.join(os.getcwd(), "build", "lib", "ollama") +PKG_BIN_DIR = os.path.join(PYTHON_PACKAGE_NAME, "bin") +PKG_LIB_DIR = os.path.join(PYTHON_PACKAGE_NAME, "lib") + +def make_executable(path): + st = os.stat(path) + os.chmod(path, st.st_mode | stat.S_IEXEC) + +class CustomBuild(build_py): + def run(self): + os.makedirs(PKG_BIN_DIR, exist_ok=True) + os.makedirs(PKG_LIB_DIR, exist_ok=True) + + # Copy ollama binary + if os.path.exists(BIN_SRC): + print(f"Copying binary to {PKG_BIN_DIR}") + shutil.copy2(BIN_SRC, PKG_BIN_DIR) + make_executable(os.path.join(PKG_BIN_DIR, "ollama")) + else: + print("Warning: ollama binary not found") + + # Copy .so libraries + if os.path.exists(LIB_SRC): + for f in os.listdir(LIB_SRC): + if f.endswith(".so"): + src = os.path.join(LIB_SRC, f) + dst = os.path.join(PKG_LIB_DIR, f) + print(f"Copying shared lib: {src}") + shutil.copy2(src, dst) + else: + print(f"Warning: {LIB_SRC} not found") + + super().run() + +setup( + name=PYTHON_PACKAGE_NAME, + version=VERSION, + author="Shalini Salomi Bodapati", + author_email="Shalini.Salomi.Bodapati@ibm.com", + description="Power10 optimized Ollama binary + shared libs as Python package", + license="MIT", + packages=find_packages(include=["ollama_python_package"]), + include_package_data=False, + cmdclass={'build_py': CustomBuild}, + package_data={PYTHON_PACKAGE_NAME: ["bin/*", "lib/*.so"]}, + python_requires=">=3.8", +) +EOF + +# Create __init__.py (wrapper) +cat <<'EOF' > ${PKG_NAME}/__init__.py +import subprocess +from pathlib import Path + +def run(args=None): + """Run embedded Ollama binary packaged with this wheel.""" + bin_path = Path(__file__).parent / "bin" / "ollama" + if not bin_path.exists(): + raise FileNotFoundError("Embedded ollama binary not found.") + subprocess.run([str(bin_path)] + (args or [])) +EOF + +echo "=============== Building wheel ==================" +python -m pip install --upgrade pip setuptools wheel build + +if ! python setup.py bdist_wheel --plat-name linux_ppc64le --dist-dir "$CURRENT_DIR/"; then + echo "============ Wheel Creation Failed =================" + EXIT_CODE=1 +else + echo "============ Wheel successfully built =================" +fi From 4da77a2887a14dd08d4e8ae7aba52e2850bd6804 Mon Sep 17 00:00:00 2001 From: shalinib-ibm Date: Tue, 19 May 2026 12:42:23 +0530 Subject: [PATCH 03/12] Create Dockerfile for ollama v0.24.0 --- o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile diff --git a/o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile b/o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile new file mode 100644 index 0000000000..d6b0c54449 --- /dev/null +++ b/o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile @@ -0,0 +1,103 @@ +############################################################################### +# Stage 1: Build Ollama (Power10 optimized) +############################################################################### +FROM registry.access.redhat.com/ubi9/ubi:9.6 AS build + +ARG PACKAGE_NAME=ollama +ARG PACKAGE_VERSION=v0.24.0 +ARG PACKAGE_URL=https://github.com/ollama/ollama +ENV CMAKE_VERSION=3.30.5 +ENV GO_VERSION=1.26.1 +ENV PATH="/usr/local/go/bin:/usr/local/cmake/bin:${PATH}" + +# Install dependencies +RUN yum update -y && \ + yum install -y \ + python3 python3-pip python3-devel \ + gcc-toolset-13 gcc-toolset-13-binutils gcc-toolset-13-gcc-c++ \ + git make cmake binutils wget patch tar gzip openssl-devel \ + && yum clean all + +# Enable GCC toolset 13 +ENV PATH="/opt/rh/gcc-toolset-13/root/usr/bin:${PATH}" +ENV LD_LIBRARY_PATH="/opt/rh/gcc-toolset-13/root/usr/lib64:${LD_LIBRARY_PATH}" +ENV CC=/opt/rh/gcc-toolset-13/root/usr/bin/gcc +ENV CXX=/opt/rh/gcc-toolset-13/root/usr/bin/g++ + +# Install CMake +WORKDIR /tmp +RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz && \ + tar -xzf cmake-${CMAKE_VERSION}.tar.gz && \ + cd cmake-${CMAKE_VERSION} && \ + ./bootstrap --prefix=/usr/local/cmake --parallel=2 -- \ + -DBUILD_TESTING:BOOL=OFF \ + -DCMAKE_BUILD_TYPE:STRING=Release \ + -DCMAKE_USE_OPENSSL:BOOL=ON && \ + make -j$(nproc) && \ + make install && \ + cmake --version + +# Install Go +RUN wget https://go.dev/dl/go${GO_VERSION}.linux-ppc64le.tar.gz && \ + rm -rf /usr/local/go && \ + tar -C /usr/local -xzf go${GO_VERSION}.linux-ppc64le.tar.gz && \ + rm -rf go${GO_VERSION}.linux-ppc64le.tar.gz && \ + go version + +############################################################################### +# Clone and patch Ollama +############################################################################### +WORKDIR /src + +# Clone Ollama source and apply patches +RUN git clone ${PACKAGE_URL} && \ + cd ${PACKAGE_NAME} && \ + git checkout ${PACKAGE_VERSION} + +WORKDIR /src/${PACKAGE_NAME} +# Download patches +RUN wget -q -O ppc_sync1.patch \ + https://github.com/ollama/ollama/commit/035aee3b98e666b42fbab724aa9aaa176360844f.patch && \ + wget -q -O ppc_sync2.patch \ + https://github.com/ollama/ollama/commit/b765e03d192fe99e96a8008daeb76a0a843e997d.patch && \ + wget -q -O build_fix_ppc.patch \ + https://github.com/ollama/ollama/commit/4115e4f58f8c3fb86cdce2d58aae811c2d26cc52.patch && \ + wget -q -O set_threads_env.patch \ + https://raw.githubusercontent.com/ppc64le/build-scripts/refs/heads/master/o/ollama/set_threads_env_v0.24.0.patch + +# Apply patches +RUN patch -Np1 < ppc_sync1.patch && \ + patch -Np1 < ppc_sync2.patch && \ + patch -Np1 < ppc_build_fix.patch && \ + patch -Np1 < set_threads_env.patch + +############################################################################### +# Build Ollama (CMake + Go) +############################################################################### +RUN cmake -B build -DCMAKE_BUILD_TYPE=Release && \ + cmake --build build -j$(nproc) + +# Link GGML Power10 libs +ENV CGO_LDFLAGS="-L/src/ollama/build/lib/ollama -lggml-cpu-power10" + +RUN go build --tags ppc64le.power10 -o /src/ollama/ollama . + +############################################################################### +# Stage 2: Small runtime image +############################################################################### +FROM registry.access.redhat.com/ubi9/ubi:9.6 + +RUN yum update -y && \ + yum install -y libatomic openblas-devel && \ + yum clean all + +COPY --from=build /src/ollama/ollama /usr/bin/ollama +COPY --from=build /src/ollama/build/lib/ollama /usr/lib/ollama + +ENV LD_LIBRARY_PATH=/usr/lib/ollama:$LD_LIBRARY_PATH +ENV PATH="/usr/bin:${PATH}" +ENV OLLAMA_HOST=0.0.0.0:11434 + +EXPOSE 11434 +ENTRYPOINT ["/usr/bin/ollama"] +CMD ["serve"] From ed2193caf4c545b706a3f5597255510a03a94803 Mon Sep 17 00:00:00 2001 From: shalinib-ibm Date: Tue, 19 May 2026 15:57:40 +0530 Subject: [PATCH 04/12] Update set_threads_env_v0.24.0.patch --- o/ollama/set_threads_env_v0.24.0.patch | 36 ++++++++++++-------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/o/ollama/set_threads_env_v0.24.0.patch b/o/ollama/set_threads_env_v0.24.0.patch index 69e150cea9..4c021b6bc5 100644 --- a/o/ollama/set_threads_env_v0.24.0.patch +++ b/o/ollama/set_threads_env_v0.24.0.patch @@ -1,46 +1,44 @@ diff --git a/discover/gpu.go b/discover/gpu.go -index 4a7d552d..789d6c8d 100644 +index 4a7d552d..103c96ff 100644 --- a/discover/gpu.go +++ b/discover/gpu.go @@ -9,6 +9,7 @@ import ( "strings" "time" - + + "github.com/ollama/ollama/envconfig" "github.com/ollama/ollama/logutil" "github.com/ollama/ollama/ml" ) -@@ -40,6 +41,11 @@ func GetSystemInfo() ml.SystemInfo { +@@ -39,6 +40,10 @@ func GetSystemInfo() ml.SystemInfo { + // Fall back to Go's num CPU threadCount = runtime.NumCPU() } - -+ if userThreadCount := envconfig.NumThreads(); userThreadCount > 0 { ++ if userThreadCount := envconfig.NumThreads(); userThreadCount > 0 { + slog.Info("user override thread count", "override", userThreadCount, "default", threadCount) + threadCount = int(userThreadCount) + } -+ + return ml.SystemInfo{ ThreadCount: threadCount, - TotalMemory: memInfo.TotalMemory, diff --git a/envconfig/config.go b/envconfig/config.go -index f4bd4aa6..b10307d1 100644 +index f4bd4aa6..1e821b3d 100644 --- a/envconfig/config.go +++ b/envconfig/config.go -@@ -271,6 +271,8 @@ func Uint(key string, defaultValue uint) func() uint { - } - +@@ -273,6 +273,8 @@ func Uint(key string, defaultValue uint) func() uint { var ( -+ // NumThreads overrides the default inference thread count. -+ NumThreads = Uint("OLLAMA_NUM_THREADS", 0) // NumParallel sets the number of parallel model requests. NumParallel can be configured via the OLLAMA_NUM_PARALLEL environment variable. NumParallel = Uint("OLLAMA_NUM_PARALLEL", 1) ++ // NumThreads overrides the default inference thread count. ++ NumThreads = Uint("OLLAMA_NUM_THREADS", 0) // MaxRunners sets the maximum number of loaded models. MaxRunners can be configured via the OLLAMA_MAX_LOADED_MODELS environment variable. -@@ -324,6 +326,7 @@ func AsMap() map[string]EnvVar { - "OLLAMA_MAX_QUEUE": {"OLLAMA_MAX_QUEUE", MaxQueue(), "Maximum number of queued requests"}, - "OLLAMA_MODELS": {"OLLAMA_MODELS", Models(), "The path to the models directory"}, - "OLLAMA_NO_CLOUD": {"OLLAMA_NO_CLOUD", NoCloud(), "Disable Ollama cloud features (remote inference and web search)"}, -+ "OLLAMA_NUM_THREADS": {"OLLAMA_NUM_THREADS", NumThreads(), "Override the default cpu inference thread count"}, + MaxRunners = Uint("OLLAMA_MAX_LOADED_MODELS", 0) + // MaxQueue sets the maximum number of queued requests. MaxQueue can be configured via the OLLAMA_MAX_QUEUE environment variable. +@@ -327,6 +329,7 @@ func AsMap() map[string]EnvVar { "OLLAMA_NOHISTORY": {"OLLAMA_NOHISTORY", NoHistory(), "Do not preserve readline history"}, "OLLAMA_NOPRUNE": {"OLLAMA_NOPRUNE", NoPrune(), "Do not prune model blobs on startup"}, "OLLAMA_NUM_PARALLEL": {"OLLAMA_NUM_PARALLEL", NumParallel(), "Maximum number of parallel requests"}, - ++ "OLLAMA_NUM_THREADS": {"OLLAMA_NUM_THREADS", NumThreads(), "Override the default cpu inference thread count"}, + "OLLAMA_ORIGINS": {"OLLAMA_ORIGINS", AllowedOrigins(), "A comma separated list of allowed origins"}, + "OLLAMA_SCHED_SPREAD": {"OLLAMA_SCHED_SPREAD", SchedSpread(), "Always schedule model across all GPUs"}, + "OLLAMA_MULTIUSER_CACHE": {"OLLAMA_MULTIUSER_CACHE", MultiUserCache(), "Optimize prompt caching for multi-user scenarios"}, From cdb9d086d4fc65251f394956e157ae7ec0bee48e Mon Sep 17 00:00:00 2001 From: shalinib-ibm Date: Tue, 19 May 2026 16:04:48 +0530 Subject: [PATCH 05/12] Update ollama_v0.24.0_ubi_9.6.sh --- o/ollama/ollama_v0.24.0_ubi_9.6.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/o/ollama/ollama_v0.24.0_ubi_9.6.sh b/o/ollama/ollama_v0.24.0_ubi_9.6.sh index 05acd868a5..67474d9aac 100644 --- a/o/ollama/ollama_v0.24.0_ubi_9.6.sh +++ b/o/ollama/ollama_v0.24.0_ubi_9.6.sh @@ -80,7 +80,7 @@ echo "** Applying power specific patches**" patch -p1 < ppc_sync1.patch patch -p1 < ppc_sync2.patch patch -p1 < ppc_build_fix.patch -patch -p1 < set_threads_env.patch +patch -p1 < ${SCRIPT_PATH}/set_threads_env_${PACKAGE_VERSION}.patch # ----------------------------------------------------------------------------- # Build Ollama From 58a0df1ca33044cd5a311dd700f7e3b057ea70a4 Mon Sep 17 00:00:00 2001 From: shalinib-ibm Date: Tue, 19 May 2026 16:05:39 +0530 Subject: [PATCH 06/12] Update ollama_v0.24.0_ubi_9.6.sh --- o/ollama/ollama_v0.24.0_ubi_9.6.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/o/ollama/ollama_v0.24.0_ubi_9.6.sh b/o/ollama/ollama_v0.24.0_ubi_9.6.sh index 67474d9aac..34e893a8a2 100644 --- a/o/ollama/ollama_v0.24.0_ubi_9.6.sh +++ b/o/ollama/ollama_v0.24.0_ubi_9.6.sh @@ -74,7 +74,6 @@ echo "** Downloading power specific patches **" wget -q -O ppc_sync1.patch https://github.com/ollama/ollama/commit/035aee3b98e666b42fbab724aa9aaa176360844f.patch wget -q -O ppc_sync2.patch https://github.com/ollama/ollama/commit/b765e03d192fe99e96a8008daeb76a0a843e997d.patch wget -q -O ppc_build_fix.patch https://github.com/ollama/ollama/commit/4115e4f58f8c3fb86cdce2d58aae811c2d26cc52.patch -wget -O set_threads_env.patch https://raw.githubusercontent.com/ppc64le/build-scripts/refs/heads/master/o/ollama/set_threads_env_v0.24.0.patch echo "** Applying power specific patches**" patch -p1 < ppc_sync1.patch From 9341aaa4717241cc9ee8065ab3ef8215bddcb048 Mon Sep 17 00:00:00 2001 From: shalinib-ibm Date: Tue, 19 May 2026 16:07:47 +0530 Subject: [PATCH 07/12] Update Dockerfile --- o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile b/o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile index d6b0c54449..8ab5dfb158 100644 --- a/o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile +++ b/o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile @@ -62,14 +62,14 @@ RUN wget -q -O ppc_sync1.patch \ https://github.com/ollama/ollama/commit/b765e03d192fe99e96a8008daeb76a0a843e997d.patch && \ wget -q -O build_fix_ppc.patch \ https://github.com/ollama/ollama/commit/4115e4f58f8c3fb86cdce2d58aae811c2d26cc52.patch && \ - wget -q -O set_threads_env.patch \ - https://raw.githubusercontent.com/ppc64le/build-scripts/refs/heads/master/o/ollama/set_threads_env_v0.24.0.patch + # Apply patches RUN patch -Np1 < ppc_sync1.patch && \ patch -Np1 < ppc_sync2.patch && \ patch -Np1 < ppc_build_fix.patch && \ patch -Np1 < set_threads_env.patch + patch -Np1 < ../set_threads_env_${PACKAGE_VERSION}.patch && \ ############################################################################### # Build Ollama (CMake + Go) From 3317bf5f58cfd4d8597f21aa7de079b4645bb830 Mon Sep 17 00:00:00 2001 From: shalinib-ibm Date: Wed, 20 May 2026 13:12:19 +0530 Subject: [PATCH 08/12] Update ollama_v0.24.0_ubi_9.6.sh --- o/ollama/ollama_v0.24.0_ubi_9.6.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/o/ollama/ollama_v0.24.0_ubi_9.6.sh b/o/ollama/ollama_v0.24.0_ubi_9.6.sh index 34e893a8a2..31d24a3a67 100644 --- a/o/ollama/ollama_v0.24.0_ubi_9.6.sh +++ b/o/ollama/ollama_v0.24.0_ubi_9.6.sh @@ -74,12 +74,13 @@ echo "** Downloading power specific patches **" wget -q -O ppc_sync1.patch https://github.com/ollama/ollama/commit/035aee3b98e666b42fbab724aa9aaa176360844f.patch wget -q -O ppc_sync2.patch https://github.com/ollama/ollama/commit/b765e03d192fe99e96a8008daeb76a0a843e997d.patch wget -q -O ppc_build_fix.patch https://github.com/ollama/ollama/commit/4115e4f58f8c3fb86cdce2d58aae811c2d26cc52.patch +wget -q -O set_threads_env.patch https://github.com/ollama/ollama/commit/93e98dcc345e34cebd18ac7a83cf08a9b646fd52.patch echo "** Applying power specific patches**" patch -p1 < ppc_sync1.patch patch -p1 < ppc_sync2.patch patch -p1 < ppc_build_fix.patch -patch -p1 < ${SCRIPT_PATH}/set_threads_env_${PACKAGE_VERSION}.patch +patch -p1 < set_threads_env.patch # ----------------------------------------------------------------------------- # Build Ollama From cd0faafcd1e6a5edb6c1ab3f1f1dd6ea93476f4c Mon Sep 17 00:00:00 2001 From: shalinib-ibm Date: Wed, 20 May 2026 13:12:48 +0530 Subject: [PATCH 09/12] Delete o/ollama/set_threads_env_v0.24.0.patch Patch is being fetched from upstream --- o/ollama/set_threads_env_v0.24.0.patch | 44 -------------------------- 1 file changed, 44 deletions(-) delete mode 100644 o/ollama/set_threads_env_v0.24.0.patch diff --git a/o/ollama/set_threads_env_v0.24.0.patch b/o/ollama/set_threads_env_v0.24.0.patch deleted file mode 100644 index 4c021b6bc5..0000000000 --- a/o/ollama/set_threads_env_v0.24.0.patch +++ /dev/null @@ -1,44 +0,0 @@ -diff --git a/discover/gpu.go b/discover/gpu.go -index 4a7d552d..103c96ff 100644 ---- a/discover/gpu.go -+++ b/discover/gpu.go -@@ -9,6 +9,7 @@ import ( - "strings" - "time" - -+ "github.com/ollama/ollama/envconfig" - "github.com/ollama/ollama/logutil" - "github.com/ollama/ollama/ml" - ) -@@ -39,6 +40,10 @@ func GetSystemInfo() ml.SystemInfo { - // Fall back to Go's num CPU - threadCount = runtime.NumCPU() - } -+ if userThreadCount := envconfig.NumThreads(); userThreadCount > 0 { -+ slog.Info("user override thread count", "override", userThreadCount, "default", threadCount) -+ threadCount = int(userThreadCount) -+ } - - return ml.SystemInfo{ - ThreadCount: threadCount, -diff --git a/envconfig/config.go b/envconfig/config.go -index f4bd4aa6..1e821b3d 100644 ---- a/envconfig/config.go -+++ b/envconfig/config.go -@@ -273,6 +273,8 @@ func Uint(key string, defaultValue uint) func() uint { - var ( - // NumParallel sets the number of parallel model requests. NumParallel can be configured via the OLLAMA_NUM_PARALLEL environment variable. - NumParallel = Uint("OLLAMA_NUM_PARALLEL", 1) -+ // NumThreads overrides the default inference thread count. -+ NumThreads = Uint("OLLAMA_NUM_THREADS", 0) - // MaxRunners sets the maximum number of loaded models. MaxRunners can be configured via the OLLAMA_MAX_LOADED_MODELS environment variable. - MaxRunners = Uint("OLLAMA_MAX_LOADED_MODELS", 0) - // MaxQueue sets the maximum number of queued requests. MaxQueue can be configured via the OLLAMA_MAX_QUEUE environment variable. -@@ -327,6 +329,7 @@ func AsMap() map[string]EnvVar { - "OLLAMA_NOHISTORY": {"OLLAMA_NOHISTORY", NoHistory(), "Do not preserve readline history"}, - "OLLAMA_NOPRUNE": {"OLLAMA_NOPRUNE", NoPrune(), "Do not prune model blobs on startup"}, - "OLLAMA_NUM_PARALLEL": {"OLLAMA_NUM_PARALLEL", NumParallel(), "Maximum number of parallel requests"}, -+ "OLLAMA_NUM_THREADS": {"OLLAMA_NUM_THREADS", NumThreads(), "Override the default cpu inference thread count"}, - "OLLAMA_ORIGINS": {"OLLAMA_ORIGINS", AllowedOrigins(), "A comma separated list of allowed origins"}, - "OLLAMA_SCHED_SPREAD": {"OLLAMA_SCHED_SPREAD", SchedSpread(), "Always schedule model across all GPUs"}, - "OLLAMA_MULTIUSER_CACHE": {"OLLAMA_MULTIUSER_CACHE", MultiUserCache(), "Optimize prompt caching for multi-user scenarios"}, From 40b17b15f985baa6d8799801e7b652bddbc0d039 Mon Sep 17 00:00:00 2001 From: shalinib-ibm Date: Wed, 20 May 2026 13:15:42 +0530 Subject: [PATCH 10/12] Update Dockerfile --- o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile b/o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile index 8ab5dfb158..ed16cb99e5 100644 --- a/o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile +++ b/o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile @@ -62,14 +62,15 @@ RUN wget -q -O ppc_sync1.patch \ https://github.com/ollama/ollama/commit/b765e03d192fe99e96a8008daeb76a0a843e997d.patch && \ wget -q -O build_fix_ppc.patch \ https://github.com/ollama/ollama/commit/4115e4f58f8c3fb86cdce2d58aae811c2d26cc52.patch && \ - + wget -q -O set_threads_env.patch \ + https://github.com/ollama/ollama/commit/93e98dcc345e34cebd18ac7a83cf08a9b646fd52.patch # Apply patches RUN patch -Np1 < ppc_sync1.patch && \ patch -Np1 < ppc_sync2.patch && \ patch -Np1 < ppc_build_fix.patch && \ patch -Np1 < set_threads_env.patch - patch -Np1 < ../set_threads_env_${PACKAGE_VERSION}.patch && \ + ############################################################################### # Build Ollama (CMake + Go) From b586f890e5165750d1208867b22a2b3e20f3472c Mon Sep 17 00:00:00 2001 From: shalinib-ibm Date: Wed, 20 May 2026 15:55:14 +0530 Subject: [PATCH 11/12] Update build_info.json --- o/ollama/build_info.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/o/ollama/build_info.json b/o/ollama/build_info.json index f61fa635db..45316e1266 100644 --- a/o/ollama/build_info.json +++ b/o/ollama/build_info.json @@ -2,7 +2,7 @@ "maintainer": "shalinib-ibm", "package_name": "ollama", "github_url": "https://github.com/ollama/ollama", - "version": "v0.23.1", + "version": "v0.24.0", "wheel_build": true, "package_dir": "o/ollama", "default_branch": "main", @@ -11,6 +11,12 @@ "validate_build_script": true, "docker_cmd": "docker build -t ${package_name}-ppc64le:$PACKAGE_VERSION ${dir}", "use_non_root_user": false, + "v0.24.0": { + "dir": "v0.24.0_ubi_9", + "build_script": "ollama_v0.24.0_ubi_9.6.sh", + "base_docker_image": "registry.access.redhat.com/ubi9/ubi:9.6", + "base_docker_variant": "redhat" + }, "v0.23.1": { "dir": "v0.23.1_ubi_9", "build_script": "ollama_v0.20.3_ubi_9.6.sh", From f820c1e8866a305633257321419dbf5240c27c0d Mon Sep 17 00:00:00 2001 From: shalinib-ibm Date: Wed, 20 May 2026 16:38:54 +0530 Subject: [PATCH 12/12] Update Dockerfile --- o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile b/o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile index ed16cb99e5..3d0b0b92fd 100644 --- a/o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile +++ b/o/ollama/Dockerfiles/v0.24.0_ubi_9/Dockerfile @@ -68,7 +68,7 @@ RUN wget -q -O ppc_sync1.patch \ # Apply patches RUN patch -Np1 < ppc_sync1.patch && \ patch -Np1 < ppc_sync2.patch && \ - patch -Np1 < ppc_build_fix.patch && \ + patch -Np1 < build_fix_ppc.patch && \ patch -Np1 < set_threads_env.patch