From 3637c087c5f50b1cc6cdf7ac1fb04662016a4b04 Mon Sep 17 00:00:00 2001 From: Brett Viren Date: Fri, 27 Sep 2024 04:13:54 -0400 Subject: [PATCH] ollama: add v0.3.9, and cuda variant (#46204) Signed-off-by: Teague Sterling Co-authored-by: brettviren Co-authored-by: Teague Sterling --- .../repos/builtin/packages/ollama/package.py | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/var/spack/repos/builtin/packages/ollama/package.py b/var/spack/repos/builtin/packages/ollama/package.py index 98a171998fc..7de54a4ce8a 100644 --- a/var/spack/repos/builtin/packages/ollama/package.py +++ b/var/spack/repos/builtin/packages/ollama/package.py @@ -7,41 +7,44 @@ from spack.package import * -class Ollama(GoPackage): +class Ollama(GoPackage, CudaPackage): """Run Llama 2, Code Llama, and other models. Customize and create your own.""" homepage = "https://ollama.com" git = "https://github.com/ollama/ollama.git" - maintainers("teaguesterling") + maintainers("teaguesterling", "brettviren") - # We're using commit IDs because the `go generate` process will fail for some - # dependencies that expect to be within a git repo. This is also an issue with - # cached downloads, but I don't know how to fix that yet - version("0.1.31", commit="dc011d16b9ff160c0be3829fc39a43054f0315d0", submodules=True) - # This is the last verified non-preview version as of 20240413 - version( - "0.1.30", - commit="756c2575535641f1b96d94b4214941b90f4c30c7", - submodules=True, - preferred=True, - ) + # A shell script is run by `go generate` which assumes source is in a git + # repo. So we must use git VCS and not tarballs and defeat source caching. + with default_args(submodules=True, no_cache=True): + version("0.3.9", commit="a1cef4d0a5f31280ea82b350605775931a6163cb") + version("0.1.31", commit="dc011d16b9ff160c0be3829fc39a43054f0315d0") + # This is the last verified non-preview version as of 20240413 + version("0.1.30", commit="756c2575535641f1b96d94b4214941b90f4c30c7") depends_on("c", type="build") # generated depends_on("cxx", type="build") # generated license("MIT", checked_by="teaguesterling") - depends_on("cmake", type="build") - depends_on("go", type="build") - depends_on("gcc", type="build") + depends_on("cmake@3.24:", type="build") + depends_on("go@1.4.0:", type="build") depends_on("git", type="build") - depends_on("ccache", type="build") class GoBuilder(spack.build_systems.go.GoBuilder): phases = ("generate", "build", "install") + def setup_build_environment(self, env): + if self.spec.satisfies("+cuda"): + # These variables are consumed by gen_linux.sh which is called by + # "go generate". + cuda_prefix = self.spec["cuda"].prefix + env.set("CUDACXX", cuda_prefix.bin.nvcc) + env.set("CUDA_LIB_DIR", cuda_prefix.lib) + env.set("CMAKE_CUDA_ARCHITECTURES", spec.variants["cuda_arch"].value) + @property def generate_args(self): """Arguments for ``go generate``."""