Created
February 15, 2025 14:49
-
-
Save sukanka/2bad26b2071f82f8e10727ee8a1ea99d to your computer and use it in GitHub Desktop.
PKGBUILD for ollama with Maciej-Mogilany:AMD_APU_GTT_memory patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Maintainer: Alexander F. Rødseth <[email protected]> | |
# Maintainer: Sven-Hendrik Haase <[email protected]> | |
# Contributor: Steven Allen <[email protected]> | |
# Contributor: Matt Harrison <[email protected]> | |
# Contributor: Kainoa Kanter <[email protected]> | |
pkgbase=ollama | |
pkgname=(ollama ollama-rocm ollama-cuda ollama-docs) | |
pkgver=0.5.11 | |
pkgrel=1 | |
pkgdesc='Create, run and share large language models (LLMs)' | |
arch=(x86_64) | |
url='https://github.com/ollama/ollama' | |
license=(MIT) | |
options=('!lto') | |
makedepends=(cmake ninja git go hipblas cuda clblast) | |
source=(git+https://github.com/ollama/ollama#tag=v$pkgver | |
amd.patch::https://github.com/ollama/ollama/pull/6282.patch | |
ollama-ld.conf | |
ollama.service | |
sysusers.conf | |
tmpfiles.d) | |
b2sums=('0d55578b2a0b06803f4aaea4a69eb32c5abfa914cb59b9a779ae8b7dd4df4c51a03135285e877a672d7652de6b651edeb366ee32c9c8549c1b0e8e2b9cabc464' | |
'a60ed0ff3b1d3d857c354e8c25664bef50a235594e5dfe85b8c390013a2a5426185ff915a6e4fae4ef3be1dc6724a80c771945356c2167339bc1f9abfece72ea' | |
'121a7854b5a7ffb60226aaf22eed1f56311ab7d0a5630579525211d5c096040edbcfd2608169a4b6d83e8b4e4855dbb22f8ebf3d52de78a34ea3d4631b7eff36' | |
'031e0809a7f564de87017401c83956d43ac29bd0e988b250585af728b952a27d139b3cad0ab1e43750e2cd3b617287d3b81efc4a70ddd61709127f68bd15eabd' | |
'68622ac2e20c1d4f9741c57d2567695ec7b5204ab43356d164483cd3bc9da79fad72489bb33c8a17c2e5cb3b142353ed5f466ce857b0f46965426d16fb388632' | |
'e8f2b19e2474f30a4f984b45787950012668bf0acb5ad1ebb25cd9776925ab4a6aa927f8131ed53e35b1c71b32c504c700fe5b5145ecd25c7a8284373bb951ed') | |
prepare() { | |
patch -d ollama -p1 <./amd.patch | |
} | |
build() { | |
export CGO_CPPFLAGS="${CPPFLAGS}" | |
export CGO_CFLAGS="${CFLAGS}" | |
export CGO_CXXFLAGS="${CXXFLAGS}" | |
export CGO_LDFLAGS="${LDFLAGS}" | |
export GOPATH="${srcdir}" | |
export GOFLAGS="-buildmode=pie -mod=readonly -modcacherw '-ldflags=-linkmode=external -compressdwarf=false -X=github.com/ollama/ollama/version.Version=$pkgver -X=github.com/ollama/ollama/server.mode=release'" | |
cd ollama | |
# Remove the runtime dependencies from installation so CMake doesn't install | |
# lots of system dependencies into the target path. | |
sed -i 's/PRE_INCLUDE_REGEXES.*/PRE_INCLUDE_REGEXES = ""/' CMakeLists.txt | |
# Sync GPU targets from CMakePresets.json | |
cmake -B build -G Ninja \ | |
-DCMAKE_CUDA_ARCHITECTURES="50;52;53;60;61;62;70;72;75;80;86;87;89;90;90a" \ | |
-DAMDGPU_TARGETS="gfx900;gfx940;gfx941;gfx942;gfx1010;gfx1012;gfx1030;gfx1100;gfx1101;gfx1102;gfx906:xnack-;gfx908:xnack-;gfx90a:xnack+;gfx90a:xnack-" \ | |
-DCMAKE_INSTALL_PREFIX=/usr | |
cmake --build build | |
go build . | |
} | |
check() { | |
ollama/ollama --version > /dev/null | |
cd ollama | |
go test . | |
} | |
package_ollama() { | |
DESTDIR="$pkgdir" cmake --install ollama/build --component CPU | |
install -Dm755 $pkgname/ollama "$pkgdir/usr/bin/ollama" | |
install -dm755 "$pkgdir/var/lib/ollama" | |
install -Dm644 ollama.service "$pkgdir/usr/lib/systemd/system/ollama.service" | |
install -Dm644 sysusers.conf "$pkgdir/usr/lib/sysusers.d/ollama.conf" | |
install -Dm644 tmpfiles.d "$pkgdir/usr/lib/tmpfiles.d/ollama.conf" | |
install -Dm644 ollama/LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" | |
ln -s /var/lib/ollama "$pkgdir/usr/share/ollama" | |
} | |
package_ollama-rocm() { | |
pkgdesc='Create, run and share large language models (LLMs) with ROCm' | |
depends+=(ollama hipblas) | |
DESTDIR="$pkgdir" cmake --install ollama/build --component HIP | |
rm -rf "$pkgdir"/usr/lib/ollama/rocm/rocblas/library | |
} | |
package_ollama-cuda() { | |
pkgdesc='Create, run and share large language models (LLMs) with CUDA' | |
depends+=(ollama cuda) | |
DESTDIR="$pkgdir" cmake --install ollama/build --component CUDA | |
} | |
package_ollama-docs() { | |
pkgdesc='Documentation for Ollama' | |
install -d "$pkgdir/usr/share/doc" | |
cp -r ollama/docs "$pkgdir/usr/share/doc/ollama" | |
install -Dm644 ollama/LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment