Merge pull request #300567 from abysssol/update-ollama-0.1.30
ollama: 0.1.29 -> 0.1.30
This commit is contained in:
commit
69f41b635f
@ -1,7 +0,0 @@
|
||||
--- a/llm/llama.cpp/examples/server/CMakeLists.txt
|
||||
+++ b/llm/llama.cpp/examples/server/CMakeLists.txt
|
||||
@@ -11,3 +11,4 @@
|
||||
TARGET_LINK_LIBRARIES(${TARGET} PRIVATE ws2_32)
|
||||
endif()
|
||||
target_compile_features(${TARGET} PRIVATE cxx_std_11)
|
||||
+include (../../../ext_server/CMakeLists.txt) # ollama
|
@ -28,14 +28,32 @@
|
||||
|
||||
let
|
||||
pname = "ollama";
|
||||
version = "0.1.29";
|
||||
# don't forget to invalidate all hashes each update
|
||||
version = "0.1.30";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "jmorganca";
|
||||
repo = "ollama";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-M2G53DJF/22ZVCAb4jGjyErKO6q2argehHSV7AEef6w=";
|
||||
hash = "sha256-+cdYT5NUf00Rx0fpCvWUNg4gi+PAOmZVDUdB3omibm0=";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
vendorHash = "sha256-Lj7CBvS51RqF63c01cOCgY7BCQeCKGu794qzb/S80C0=";
|
||||
# ollama's patches of llama.cpp's example server
|
||||
# `ollama/llm/generate/gen_common.sh` -> "apply temporary patches until fix is upstream"
|
||||
# each update, these patches should be synchronized with the contents of `ollama/llm/patches/`
|
||||
llamacppPatches = [
|
||||
(preparePatch "03-load_exception.diff" "sha256-1DfNahFYYxqlx4E4pwMKQpL+XR0bibYnDFGt6dCL4TM=")
|
||||
(preparePatch "04-locale.diff" "sha256-r5nHiP6yN/rQObRu2FZIPBKpKP9yByyZ6sSI2SKj6Do=")
|
||||
];
|
||||
|
||||
preparePatch = patch: hash: fetchpatch {
|
||||
url = "file://${src}/llm/patches/${patch}";
|
||||
inherit hash;
|
||||
stripLen = 1;
|
||||
extraPrefix = "llm/llama.cpp/";
|
||||
};
|
||||
|
||||
|
||||
validAccel = lib.assertOneOf "ollama.acceleration" acceleration [ null "rocm" "cuda" ];
|
||||
|
||||
@ -45,6 +63,7 @@ let
|
||||
enableRocm = validAccel && (acceleration == "rocm") && (warnIfNotLinux "rocm");
|
||||
enableCuda = validAccel && (acceleration == "cuda") && (warnIfNotLinux "cuda");
|
||||
|
||||
|
||||
rocmClang = linkFarm "rocm-clang" {
|
||||
llvm = rocmPackages.llvm.clang;
|
||||
};
|
||||
@ -94,12 +113,6 @@ let
|
||||
buildGo122Module.override { stdenv = overrideCC stdenv gcc12; }
|
||||
else
|
||||
buildGo122Module;
|
||||
preparePatch = patch: hash: fetchpatch {
|
||||
url = "file://${src}/llm/patches/${patch}";
|
||||
inherit hash;
|
||||
stripLen = 1;
|
||||
extraPrefix = "llm/llama.cpp/";
|
||||
};
|
||||
inherit (lib) licenses platforms maintainers;
|
||||
in
|
||||
goBuild ((lib.optionalAttrs enableRocm {
|
||||
@ -110,8 +123,7 @@ goBuild ((lib.optionalAttrs enableRocm {
|
||||
CUDACXX = "${cudaToolkit}/bin/nvcc";
|
||||
CUDAToolkit_ROOT = cudaToolkit;
|
||||
}) // {
|
||||
inherit pname version src;
|
||||
vendorHash = "sha256-Lj7CBvS51RqF63c01cOCgY7BCQeCKGu794qzb/S80C0=";
|
||||
inherit pname version src vendorHash;
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
@ -133,31 +145,20 @@ goBuild ((lib.optionalAttrs enableRocm {
|
||||
metalFrameworks;
|
||||
|
||||
patches = [
|
||||
# remove uses of `git` in the `go generate` script
|
||||
# instead use `patch` where necessary
|
||||
./remove-git.patch
|
||||
# replace a hardcoded use of `g++` with `$CXX`
|
||||
./replace-gcc.patch
|
||||
|
||||
# ollama's patches of llama.cpp's example server
|
||||
# `ollama/llm/generate/gen_common.sh` -> "apply temporary patches until fix is upstream"
|
||||
(preparePatch "01-cache.diff" "sha256-VDwu/iK6taBCyscpndQiOJ3eGqonnLVwmS2rJNMBVGU=")
|
||||
(preparePatch "02-cudaleaks.diff" "sha256-nxsWgrePUMsZBWWQAjqVHWMJPzr1owH1zSJvUU7Q5pA=")
|
||||
(preparePatch "03-load_exception.diff" "sha256-1DfNahFYYxqlx4E4pwMKQpL+XR0bibYnDFGt6dCL4TM=")
|
||||
(preparePatch "04-locale.diff" "sha256-r5nHiP6yN/rQObRu2FZIPBKpKP9yByyZ6sSI2SKj6Do=")
|
||||
(preparePatch "05-fix-clip-free.diff" "sha256-EFZ+QTtZCvstVxYgVdFKHsQqdkL98T0eXOEBOqCrlL4=")
|
||||
];
|
||||
# disable uses of `git` in the `go generate` script
|
||||
# ollama's build script assumes the source is a git repo, but nix removes the git directory
|
||||
# this also disables necessary patches contained in `ollama/llm/patches/`
|
||||
# those patches are added to `llamacppPatches`, and reapplied here in the patch phase
|
||||
./disable-git.patch
|
||||
] ++ llamacppPatches;
|
||||
postPatch = ''
|
||||
# use a patch from the nix store in the `go generate` script
|
||||
substituteInPlace llm/generate/gen_common.sh \
|
||||
--subst-var-by cmakeIncludePatch '${./cmake-include.patch}'
|
||||
# `ollama/llm/generate/gen_common.sh` -> "avoid duplicate main symbols when we link into the cgo binary"
|
||||
substituteInPlace llm/llama.cpp/examples/server/server.cpp \
|
||||
--replace-fail 'int main(' 'int __main('
|
||||
# replace a hardcoded use of `g++` with `$CXX` so clang can be used on darwin
|
||||
substituteInPlace llm/generate/gen_common.sh --replace-fail 'g++' '$CXX'
|
||||
# replace inaccurate version number with actual release version
|
||||
substituteInPlace version/version.go --replace-fail 0.0.0 '${version}'
|
||||
'';
|
||||
preBuild = ''
|
||||
# disable uses of `git`, since nix removes the git directory
|
||||
export OLLAMA_SKIP_PATCHING=true
|
||||
# build llama.cpp libraries for ollama
|
||||
go generate ./...
|
||||
@ -168,9 +169,10 @@ goBuild ((lib.optionalAttrs enableRocm {
|
||||
'' + lib.optionalString (enableRocm || enableCuda) ''
|
||||
# expose runtime libraries necessary to use the gpu
|
||||
mv "$out/bin/ollama" "$out/bin/.ollama-unwrapped"
|
||||
makeWrapper "$out/bin/.ollama-unwrapped" "$out/bin/ollama" \
|
||||
--suffix LD_LIBRARY_PATH : '/run/opengl-driver/lib:${lib.makeLibraryPath runtimeLibs}' '' + lib.optionalString enableRocm ''\
|
||||
--set-default HIP_PATH ${rocmPath}
|
||||
makeWrapper "$out/bin/.ollama-unwrapped" "$out/bin/ollama" ${
|
||||
lib.optionalString enableRocm
|
||||
''--set-default HIP_PATH '${rocmPath}' ''} \
|
||||
--suffix LD_LIBRARY_PATH : '/run/opengl-driver/lib:${lib.makeLibraryPath runtimeLibs}'
|
||||
'';
|
||||
|
||||
ldflags = [
|
||||
@ -191,9 +193,9 @@ goBuild ((lib.optionalAttrs enableRocm {
|
||||
};
|
||||
|
||||
meta = {
|
||||
changelog = "https://github.com/ollama/ollama/releases/tag/v${version}";
|
||||
description = "Get up and running with large language models locally";
|
||||
homepage = "https://github.com/jmorganca/ollama";
|
||||
homepage = "https://github.com/ollama/ollama";
|
||||
changelog = "https://github.com/ollama/ollama/releases/tag/v${version}";
|
||||
license = licenses.mit;
|
||||
platforms = platforms.unix;
|
||||
mainProgram = "ollama";
|
||||
|
20
pkgs/tools/misc/ollama/disable-git.patch
Normal file
20
pkgs/tools/misc/ollama/disable-git.patch
Normal file
@ -0,0 +1,20 @@
|
||||
--- a/llm/generate/gen_common.sh
|
||||
+++ b/llm/generate/gen_common.sh
|
||||
@@ -65,6 +65,8 @@
|
||||
echo 'add_subdirectory(../ext_server ext_server) # ollama' >>${LLAMACPP_DIR}/CMakeLists.txt
|
||||
fi
|
||||
|
||||
+ return
|
||||
+
|
||||
if [ -n "$(ls -A ../patches/*.diff)" ]; then
|
||||
# apply temporary patches until fix is upstream
|
||||
for patch in ../patches/*.diff; do
|
||||
@@ -110,6 +112,8 @@
|
||||
|
||||
# Keep the local tree clean after we're done with the build
|
||||
cleanup() {
|
||||
+ return
|
||||
+
|
||||
(cd ${LLAMACPP_DIR}/ && git checkout CMakeLists.txt)
|
||||
|
||||
if [ -n "$(ls -A ../patches/*.diff)" ]; then
|
@ -1,21 +0,0 @@
|
||||
--- a/llm/generate/gen_common.sh
|
||||
+++ b/llm/generate/gen_common.sh
|
||||
@@ -60,6 +60,9 @@
|
||||
}
|
||||
|
||||
apply_patches() {
|
||||
+ patch -i '@cmakeIncludePatch@' "${LLAMACPP_DIR}/examples/server/CMakeLists.txt"
|
||||
+ return
|
||||
+
|
||||
# Wire up our CMakefile
|
||||
if ! grep ollama ${LLAMACPP_DIR}/examples/server/CMakeLists.txt; then
|
||||
echo 'include (../../../ext_server/CMakeLists.txt) # ollama' >>${LLAMACPP_DIR}/examples/server/CMakeLists.txt
|
||||
@@ -113,6 +116,8 @@
|
||||
|
||||
# Keep the local tree clean after we're done with the build
|
||||
cleanup() {
|
||||
+ return
|
||||
+
|
||||
(cd ${LLAMACPP_DIR}/examples/server/ && git checkout CMakeLists.txt server.cpp)
|
||||
|
||||
if [ -n "$(ls -A ../patches/*.diff)" ]; then
|
@ -1,11 +0,0 @@
|
||||
--- a/llm/generate/gen_common.sh
|
||||
+++ b/llm/generate/gen_common.sh
|
||||
@@ -86,7 +89,7 @@
|
||||
cmake -S ${LLAMACPP_DIR} -B ${BUILD_DIR} ${CMAKE_DEFS}
|
||||
cmake --build ${BUILD_DIR} ${CMAKE_TARGETS} -j8
|
||||
mkdir -p ${BUILD_DIR}/lib/
|
||||
- g++ -fPIC -g -shared -o ${BUILD_DIR}/lib/libext_server.${LIB_EXT} \
|
||||
+ $CXX -fPIC -g -shared -o ${BUILD_DIR}/lib/libext_server.${LIB_EXT} \
|
||||
${GCC_ARCH} \
|
||||
${WHOLE_ARCHIVE} ${BUILD_DIR}/examples/server/libext_server.a ${NO_WHOLE_ARCHIVE} \
|
||||
${BUILD_DIR}/common/libcommon.a \
|
Loading…
Reference in New Issue
Block a user