Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ollama: 0.5.1 -> 0.5.4 #365718

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 31 additions & 22 deletions pkgs/by-name/ol/ollama/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
cudaPackages,
darwin,
autoAddDriverRunpath,
versionCheckHook,

# passthru
nixosTests,
testers,
ollama,
Expand All @@ -41,13 +43,13 @@ assert builtins.elem acceleration [
let
pname = "ollama";
# don't forget to invalidate all hashes each update
version = "0.5.1";
version = "0.5.4";

src = fetchFromGitHub {
owner = "ollama";
repo = "ollama";
rev = "v${version}";
hash = "sha256-llsK/rMK1jf2uneqgon9gqtZcbC9PuCDxoYfC7Ta6PY=";
tag = "v${version}";
hash = "sha256-JyP7A1+u9Vs6ynOKDwun1qLBsjN+CVHIv39Hh2TYa2U=";
fetchSubmodules = true;
};

Expand Down Expand Up @@ -169,14 +171,10 @@ goBuild {
++ lib.optionals enableCuda cudaLibs
++ lib.optionals stdenv.hostPlatform.isDarwin metalFrameworks;

patches = [
# ollama's build script is unable to find hipcc
./rocm.patch
];

Comment on lines -172 to -176
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upstream reorganized the make files

$ cat make/rocm-defs.make

# Common definitions for the various Makefiles which set cuda settings
# No rules are defined here so this is safe to include at the beginning of other makefiles

ifeq ($(OS),windows)
	HIP_COMPILER:=$(wildcard $(HIP_PATH)/bin/hipcc.bin.exe)
else ifeq ($(OS),linux)
	HIP_PATH?=$(shell ls -d /opt/rocm 2>/dev/null)
	HIP_COMPILER:=$(wildcard $(HIP_PATH)/bin/hipcc)
endif

I'm not sure if we need to make a new patch yet as I got another error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seemed like this patch was now unneeded... I could be wrong though.

# replace inaccurate version number with actual release version
postPatch = ''
# replace inaccurate version number with actual release version
substituteInPlace version/version.go --replace-fail 0.0.0 '${version}'
substituteInPlace version/version.go \
--replace-fail 0.0.0 '${version}'
'';

overrideModAttrs = (
Expand All @@ -186,25 +184,28 @@ goBuild {
}
);

preBuild = ''
preBuild =
let
dist_cmd =
if cudaRequested then
"dist_cuda_v${cudaMajorVersion}"
else if rocmRequested then
"dist_rocm"
else
"dist";
in
# build llama.cpp libraries for ollama
make -j $NIX_BUILD_CORES
'';

postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
# copy libggml_*.so and runners into lib
# https://github.com/ollama/ollama/blob/v0.4.4/llama/make/gpu.make#L90
mkdir -p $out/lib
cp -r dist/*/lib/* $out/lib/
'';
Comment on lines -194 to -199
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be the problem? I'm going to some messing around

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it working locally! PR coming shortly

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. thanks!

''
make ${dist_cmd} -j $NIX_BUILD_CORES
'';

postFixup =
# the app doesn't appear functional at the moment, so hide it
''
# the app doesn't appear functional at the moment, so hide it
mv "$out/bin/app" "$out/bin/.ollama-app"
''
# expose runtime libraries necessary to use the gpu
+ lib.optionalString (enableRocm || enableCuda) ''
# expose runtime libraries necessary to use the gpu
wrapProgram "$out/bin/ollama" ${wrapperArgs}
'';

Expand All @@ -215,6 +216,14 @@ goBuild {
"-X=github.com/ollama/ollama/server.mode=release"
];

__darwinAllowLocalNetworking = true;

nativeInstallCheck = [
versionCheckHook
];
versionCheckProgramArg = [ "--version" ];
doInstallCheck = true;

passthru = {
tests =
{
Expand Down
13 changes: 0 additions & 13 deletions pkgs/by-name/ol/ollama/rocm.patch

This file was deleted.