From nobody Fri Aug 09 05:03:38 2024 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WgBdQ3XMjz5SlBK; Fri, 09 Aug 2024 05:03:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WgBdQ2XVKz4cmH; Fri, 9 Aug 2024 05:03:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723179818; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Df39S+D2o5yc79YlRdTcYZMDN3ObAv7LojH5/eWqSv4=; b=aWVSfIZZQjB7MChP/UD0zlIjgH+jJO14rlpejrk/t7D/ySZSoA2nzyi1V8lb+D6pMu2232 KKNa6udmWY7E0sleofgjAHur6q8O808YFPcK2DLlKuSpHngVe8xkN0sjOGe2ZnbLBDIqB6 VufgksdDkFL1SlY37MX0A1S1B4C3WSB2fFFIU1Neutbc93+Kuux+kKnLDLO7upKAMrln8M TnLKACScXIcfDELHhkHE5/P9TuTVvzVrBLDYnS2ywFesyPzFPaccWUR/qgCshvBwfm+1OC v6FW1zeG+6Ts572upFCAmaWcKMx4VCEXQdqtYMw9oQMjD425t96+sRpSrxNkoA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723179818; a=rsa-sha256; cv=none; b=OV0ccLeHg7WrqYFL4yiQ9xKUlRObDbrgMjM1ps6H2GY3e036CglqfQhXrF2NMmDl79CyDa BQIwWt9Lw46obr6GQ4zl20yj8xP0P71v4TXLWTOrQ9U/BypZ/0mKFlIyA7G5479LkmVIdE eu2iz5VupSlRCdpDu6PjLzQc6sbSpnrsF8cF2JiA8x8Da7nMLVAq2SiVOQ+kofbifLbdmk 0VRs9aD7nS1Z7JvIhHotB5m/jNYmD3PEJyttlYBLrQowkHepWlvt0Hc0zXdvheGgrjz0ii OrcGj1bzvrzMsbjnAwE6wsm0ram6Ney8A4xJ45cRLl2urvHZYWG6hitdHW11pw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723179818; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Df39S+D2o5yc79YlRdTcYZMDN3ObAv7LojH5/eWqSv4=; b=l4RRuQM0CE7ol/edXbU6U2sK3dtAlr0Eie1mYUl9WWjT8aFj2QiM+mankQE0QvHudErl+3 ighVuWXuOOKrLkO54ez6r3NAPkUF1Vmrm0IgLF8n1DzFujbUQ/pMMiNPexBYyZ1kM0/fIj y45F1PE/cvavWw2gX0oGeuQk2wRoFA/SeffapZGWdGroHmLyK08vPlL+QceJM9ySG2ivGi 542KsLSvyJKUoz5CXUYgGkXCK9Pj7lg1SxVGD4YrKtcfu5XkRwWSNSEgTvvluT8of0vFP0 zwg3wMz/hHt3QWhzaPru7E1XKVHxxx0XA7nBnlf/eWMdYbJH/AmAY3YYnXuKUA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WgBdQ1QxDz138d; Fri, 9 Aug 2024 05:03:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47953c2X031498; Fri, 9 Aug 2024 05:03:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47953cDJ031495; Fri, 9 Aug 2024 05:03:38 GMT (envelope-from git) Date: Fri, 9 Aug 2024 05:03:38 GMT Message-Id: <202408090503.47953cDJ031495@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Yuri Victorovich Subject: git: 7826eb339bbe - main - misc/ollama: Fix Vulkan compatibility List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-ports-main@freebsd.org Sender: owner-dev-commits-ports-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: yuri X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7826eb339bbede7baa4c75af69360ed9756b6de4 Auto-Submitted: auto-generated The branch main has been updated by yuri: URL: https://cgit.FreeBSD.org/ports/commit/?id=7826eb339bbede7baa4c75af69360ed9756b6de4 commit 7826eb339bbede7baa4c75af69360ed9756b6de4 Author: Yuri Victorovich AuthorDate: 2024-08-09 04:58:03 +0000 Commit: Yuri Victorovich CommitDate: 2024-08-09 05:03:35 +0000 misc/ollama: Fix Vulkan compatibility --- misc/ollama/Makefile | 7 +++++-- misc/ollama/files/patch-FreeBSD-compatibility | 12 ++++++------ ...atch-llm_llama.cpp_ggml_src_vulkan-shaders_CMakeLists.txt | 9 +++++++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/misc/ollama/Makefile b/misc/ollama/Makefile index d388e976d172..b44f692681bd 100644 --- a/misc/ollama/Makefile +++ b/misc/ollama/Makefile @@ -1,7 +1,7 @@ PORTNAME= ollama DISTVERSIONPREFIX= v DISTVERSION= 0.3.4 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= misc # machine-learning MAINTAINER= yuri@FreeBSD.org @@ -16,6 +16,7 @@ ONLY_FOR_ARCHS_REASON= bundled patched llama-cpp is placed into the arch-specifi BUILD_DEPENDS= bash:shells/bash \ cmake:devel/cmake-core \ + glslc:graphics/shaderc \ vulkan-headers>0:graphics/vulkan-headers LIB_DEPENDS= libvulkan.so:graphics/vulkan-loader @@ -27,12 +28,14 @@ GO_TARGET= . USE_GITHUB= nodefault GH_TUPLE= ggerganov:llama.cpp:6eeaeba:llama_cpp/llm/llama.cpp +MAKE_ENV= PATH=${PATH}:${WRKSRC}/llm/build/bsd/x86_64_static/bin # workaround to find vulkan-shaders-gen + PLIST_FILES= bin/${PORTNAME} post-patch: # workaround for https://github.com/ollama/ollama/issues/6259 (use of extenral libllama.so) @${REINPLACE_CMD} \ -e '\ - s| llama | llama omp |; \ + s| llama | llama ${LOCALBASE}/lib/libvulkan.so omp pthread |; \ s| llama | ${WRKSRC}/llm/build/bsd/x86_64_static/src/libllama.a |; \ s| ggml | ${WRKSRC}/llm/build/bsd/x86_64_static/ggml/src/libggml.a |; \ ' \ diff --git a/misc/ollama/files/patch-FreeBSD-compatibility b/misc/ollama/files/patch-FreeBSD-compatibility index 03cc31011ab1..ca206363f042 100644 --- a/misc/ollama/files/patch-FreeBSD-compatibility +++ b/misc/ollama/files/patch-FreeBSD-compatibility @@ -143,38 +143,38 @@ new file mode 100644 +COMMON_BSD_DEFS="-DCMAKE_SYSTEM_NAME=$(uname -s)" +CMAKE_TARGETS="--target llama --target ggml" + -+COMMON_CPU_DEFS="${COMMON_BSD_DEFS} -DCMAKE_SYSTEM_PROCESSOR=${ARCH}" ++COMMON_CPU_DEFS="${COMMON_BSD_DEFS} -DCMAKE_SYSTEM_PROCESSOR=${ARCH} -DBUILD_SHARED_LIBS=off" + +# Static build for linking into the Go binary +init_vars -+CMAKE_DEFS="${COMMON_CPU_DEFS} -DBUILD_SHARED_LIBS=off -DLLAMA_ACCELERATE=off -DLLAMA_AVX=off -DLLAMA_AVX2=off -DLLAMA_AVX512=off -DLLAMA_FMA=off -DLLAMA_F16C=off ${CMAKE_DEFS}" ++CMAKE_DEFS="${COMMON_CPU_DEFS} -DGGML_VULKAN=on -DGGML_ACCELERATE=off -DGGML_AVX=off -DGGML_AVX2=off -DGGML_AVX512=off -DGGML_FMA=off -DGGML_F16C=off ${CMAKE_DEFS}" +BUILD_DIR="../build/bsd/${ARCH}_static" +echo "Building static library" +build + +init_vars -+CMAKE_DEFS="${COMMON_CPU_DEFS} -DLLAMA_AVX=off -DLLAMA_AVX2=off -DLLAMA_AVX512=off -DLLAMA_FMA=off -DLLAMA_F16C=off ${CMAKE_DEFS}" ++CMAKE_DEFS="${COMMON_CPU_DEFS} -DGGML_AVX=off -DGGML_AVX2=off -DGGML_AVX512=off -DGGML_FMA=off -DGGML_F16C=off ${CMAKE_DEFS}" +BUILD_DIR="../build/bsd/${ARCH}/cpu" +echo "Building LCD CPU" +build +compress + +init_vars -+CMAKE_DEFS="${COMMON_CPU_DEFS} -DLLAMA_AVX=on -DLLAMA_AVX2=off -DLLAMA_AVX512=off -DLLAMA_FMA=off -DLLAMA_F16C=off ${CMAKE_DEFS}" ++CMAKE_DEFS="${COMMON_CPU_DEFS} -DGGML_AVX=on -DGGML_AVX2=off -DGGML_AVX512=off -DGGML_FMA=off -DGGML_F16C=off ${CMAKE_DEFS}" +BUILD_DIR="../build/bsd/${ARCH}/cpu_avx" +echo "Building AVX CPU" +build +compress + +init_vars -+CMAKE_DEFS="${COMMON_CPU_DEFS} -DLLAMA_AVX=on -DLLAMA_AVX2=on -DLLAMA_AVX512=off -DLLAMA_FMA=on -DLLAMA_F16C=on ${CMAKE_DEFS}" ++CMAKE_DEFS="${COMMON_CPU_DEFS} -DGGML_AVX=on -DGGML_AVX2=on -DGGML_AVX512=off -DGGML_FMA=on -DGGML_F16C=on ${CMAKE_DEFS}" +BUILD_DIR="../build/bsd/${ARCH}/cpu_avx2" +echo "Building AVX2 CPU" +build +compress + +init_vars -+CMAKE_DEFS="${COMMON_CPU_DEFS} -DLLAMA_VULKAN=on ${CMAKE_DEFS}" ++CMAKE_DEFS="${COMMON_CPU_DEFS} -DGGML_VULKAN=on ${CMAKE_DEFS}" +BUILD_DIR="../build/bsd/${ARCH}/vulkan" +echo "Building Vulkan GPU" +build diff --git a/misc/ollama/files/patch-llm_llama.cpp_ggml_src_vulkan-shaders_CMakeLists.txt b/misc/ollama/files/patch-llm_llama.cpp_ggml_src_vulkan-shaders_CMakeLists.txt new file mode 100644 index 000000000000..3ada7c2debc2 --- /dev/null +++ b/misc/ollama/files/patch-llm_llama.cpp_ggml_src_vulkan-shaders_CMakeLists.txt @@ -0,0 +1,9 @@ +--- llm/llama.cpp/ggml/src/vulkan-shaders/CMakeLists.txt.orig 2024-08-08 21:55:59 UTC ++++ llm/llama.cpp/ggml/src/vulkan-shaders/CMakeLists.txt +@@ -1,5 +1,6 @@ add_executable(${TARGET} vulkan-shaders-gen.cpp) + + set(TARGET vulkan-shaders-gen) + add_executable(${TARGET} vulkan-shaders-gen.cpp) ++target_link_libraries(${TARGET} PRIVATE pthread) + install(TARGETS ${TARGET} RUNTIME) + target_compile_features(${TARGET} PRIVATE cxx_std_11)