commit: c456e2c8ecccde7852fe4a5f7a2cf8a0f9b027cb Author: Paul Zander <negril.nx+gentoo <AT> gmail <DOT> com> AuthorDate: Sun Oct 19 20:13:26 2025 +0000 Commit: David Roman <davidroman96 <AT> gmail <DOT> com> CommitDate: Sun Oct 19 21:01:25 2025 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=c456e2c8
sci-ml/ollama: add vulkan support, ebuild fixes Closes: https://bugs.gentoo.org/948847 Signed-off-by: Paul Zander <negril.nx+gentoo <AT> gmail.com> sci-ml/ollama/ollama-0.12.6.ebuild | 35 +++++++++++++++++------------------ sci-ml/ollama/ollama-9999.ebuild | 35 +++++++++++++++++------------------ 2 files changed, 34 insertions(+), 36 deletions(-) diff --git a/sci-ml/ollama/ollama-0.12.6.ebuild b/sci-ml/ollama/ollama-0.12.6.ebuild index abda898581..d53e6630eb 100644 --- a/sci-ml/ollama/ollama-0.12.6.ebuild +++ b/sci-ml/ollama/ollama-0.12.6.ebuild @@ -39,8 +39,8 @@ X86_CPU_FLAGS=( avx_vnni ) CPU_FLAGS=( "${X86_CPU_FLAGS[@]/#/cpu_flags_x86_}" ) -IUSE="blas ${CPU_FLAGS[*]} cuda mkl rocm" -# IUSE+=" opencl vulkan" +IUSE="blas ${CPU_FLAGS[*]} cuda mkl rocm vulkan" +# IUSE+=" opencl" RESTRICT="test" @@ -57,7 +57,9 @@ COMMON_DEPEND=" dev-util/nvidia-cuda-toolkit:= ) rocm? ( - >=sci-libs/hipBLAS-5.5:= + >=dev-util/hip-${ROCM_VERSION}:= + >=sci-libs/hipBLAS-${ROCM_VERSION}:= + >=sci-libs/rocBLAS-${ROCM_VERSION}:= ) " @@ -65,6 +67,12 @@ DEPEND=" ${COMMON_DEPEND} >=dev-lang/go-1.23.4 " +BDEPEND=" + vulkan? ( + dev-util/vulkan-headers + media-libs/shaderc + ) +" RDEPEND=" ${COMMON_DEPEND} @@ -108,7 +116,7 @@ pkg_setup() { src_unpack() { # Already filter lto flags for ROCM # 963401 - if use rocm && tc-is-lto; then + if use rocm; then # copied from _rocm_strip_unsupported_flags strip-unsupported-flags export CXXFLAGS="$(test-flags-HIPCXX "${CXXFLAGS}")" @@ -136,11 +144,6 @@ src_prepare() { -e "s/ -O3//g" \ -i ml/backend/ggml/ggml/src/ggml-cpu/cpu.go || die sed - # fix library location - sed \ - -e "s#lib/ollama#$(get_libdir)/ollama#g" \ - -i CMakeLists.txt || die sed - sed \ -e "s/\"..\", \"lib\"/\"..\", \"$(get_libdir)\"/" \ -e "s#\"lib/ollama\"#\"$(get_libdir)/ollama\"#" \ @@ -241,6 +244,7 @@ src_configure() { # -DGGML_KOMPUTE="$(usex kompute)" # -DGGML_OPENCL="$(usex opencl)" # -DGGML_VULKAN="$(usex vulkan)" + "$(cmake_use_find_package vulkan Vulkan)" ) if use blas; then @@ -269,9 +273,6 @@ src_configure() { fi if use rocm; then - # 962445 - rocm_use_hipcc - mycmakeargs+=( -DCMAKE_HIP_ARCHITECTURES="$(get_amdgpu_flags)" -DCMAKE_HIP_PLATFORM="amd" @@ -280,8 +281,6 @@ src_configure() { ) local -x HIP_PATH="${ESYSROOT}/usr" - - check_amdgpu else mycmakeargs+=( -DCMAKE_HIP_COMPILER="NOTFOUND" @@ -305,10 +304,10 @@ src_compile() { VERSION="${PVR}" fi local EXTRA_GOFLAGS_LD=( - "-w" - "-s" - "\"-X=github.com/ollama/ollama/version.Version=${VERSION}\"" - "\"-X=github.com/ollama/ollama/server.mode=release\"" + # "-w" # disable DWARF generation + # "-s" # disable symbol table + "-X=github.com/ollama/ollama/version.Version=${VERSION}" + "-X=github.com/ollama/ollama/server.mode=release" ) GOFLAGS+=" '-ldflags=${EXTRA_GOFLAGS_LD[*]}'" diff --git a/sci-ml/ollama/ollama-9999.ebuild b/sci-ml/ollama/ollama-9999.ebuild index abda898581..d53e6630eb 100644 --- a/sci-ml/ollama/ollama-9999.ebuild +++ b/sci-ml/ollama/ollama-9999.ebuild @@ -39,8 +39,8 @@ X86_CPU_FLAGS=( avx_vnni ) CPU_FLAGS=( "${X86_CPU_FLAGS[@]/#/cpu_flags_x86_}" ) -IUSE="blas ${CPU_FLAGS[*]} cuda mkl rocm" -# IUSE+=" opencl vulkan" +IUSE="blas ${CPU_FLAGS[*]} cuda mkl rocm vulkan" +# IUSE+=" opencl" RESTRICT="test" @@ -57,7 +57,9 @@ COMMON_DEPEND=" dev-util/nvidia-cuda-toolkit:= ) rocm? ( - >=sci-libs/hipBLAS-5.5:= + >=dev-util/hip-${ROCM_VERSION}:= + >=sci-libs/hipBLAS-${ROCM_VERSION}:= + >=sci-libs/rocBLAS-${ROCM_VERSION}:= ) " @@ -65,6 +67,12 @@ DEPEND=" ${COMMON_DEPEND} >=dev-lang/go-1.23.4 " +BDEPEND=" + vulkan? ( + dev-util/vulkan-headers + media-libs/shaderc + ) +" RDEPEND=" ${COMMON_DEPEND} @@ -108,7 +116,7 @@ pkg_setup() { src_unpack() { # Already filter lto flags for ROCM # 963401 - if use rocm && tc-is-lto; then + if use rocm; then # copied from _rocm_strip_unsupported_flags strip-unsupported-flags export CXXFLAGS="$(test-flags-HIPCXX "${CXXFLAGS}")" @@ -136,11 +144,6 @@ src_prepare() { -e "s/ -O3//g" \ -i ml/backend/ggml/ggml/src/ggml-cpu/cpu.go || die sed - # fix library location - sed \ - -e "s#lib/ollama#$(get_libdir)/ollama#g" \ - -i CMakeLists.txt || die sed - sed \ -e "s/\"..\", \"lib\"/\"..\", \"$(get_libdir)\"/" \ -e "s#\"lib/ollama\"#\"$(get_libdir)/ollama\"#" \ @@ -241,6 +244,7 @@ src_configure() { # -DGGML_KOMPUTE="$(usex kompute)" # -DGGML_OPENCL="$(usex opencl)" # -DGGML_VULKAN="$(usex vulkan)" + "$(cmake_use_find_package vulkan Vulkan)" ) if use blas; then @@ -269,9 +273,6 @@ src_configure() { fi if use rocm; then - # 962445 - rocm_use_hipcc - mycmakeargs+=( -DCMAKE_HIP_ARCHITECTURES="$(get_amdgpu_flags)" -DCMAKE_HIP_PLATFORM="amd" @@ -280,8 +281,6 @@ src_configure() { ) local -x HIP_PATH="${ESYSROOT}/usr" - - check_amdgpu else mycmakeargs+=( -DCMAKE_HIP_COMPILER="NOTFOUND" @@ -305,10 +304,10 @@ src_compile() { VERSION="${PVR}" fi local EXTRA_GOFLAGS_LD=( - "-w" - "-s" - "\"-X=github.com/ollama/ollama/version.Version=${VERSION}\"" - "\"-X=github.com/ollama/ollama/server.mode=release\"" + # "-w" # disable DWARF generation + # "-s" # disable symbol table + "-X=github.com/ollama/ollama/version.Version=${VERSION}" + "-X=github.com/ollama/ollama/server.mode=release" ) GOFLAGS+=" '-ldflags=${EXTRA_GOFLAGS_LD[*]}'"
