diff options
author | Igor Ulyanov <disinbox@gmail.com> | 2023-10-29 20:46:49 +0300 |
---|---|---|
committer | Igor Ulyanov <disinbox@gmail.com> | 2023-10-29 21:00:11 +0300 |
commit | cdab003081956d9e75402ec4402aa8682e1b5c5b (patch) | |
tree | 2a0e0f609131b1619c4645ac7c2a1e66a30746e5 | |
parent | some rocm work for onnxruntime (still incomplete) (diff) | |
download | displacer-cdab003081956d9e75402ec4402aa8682e1b5c5b.tar.gz displacer-cdab003081956d9e75402ec4402aa8682e1b5c5b.tar.bz2 displacer-cdab003081956d9e75402ec4402aa8682e1b5c5b.zip |
llama.cpp ebuild with rocm support
Signed-off-by: Igor Ulyanov <disinbox@gmail.com>
-rw-r--r-- | dev-cpp/llama-cpp/Manifest | 1 | ||||
-rw-r--r-- | dev-cpp/llama-cpp/llama-cpp-9999.ebuild | 78 |
2 files changed, 79 insertions, 0 deletions
diff --git a/dev-cpp/llama-cpp/Manifest b/dev-cpp/llama-cpp/Manifest new file mode 100644 index 0000000..8062f78 --- /dev/null +++ b/dev-cpp/llama-cpp/Manifest @@ -0,0 +1 @@ +EBUILD llama-cpp-9999.ebuild 1728 BLAKE2B 04f41b05672133b14185d4426d66a79a4f06309f0071c38e5767eb9f78ee81f567ef813804839bd987a2700bf3d48a3bb35ab8999923fa2c1dc30246252230ce SHA512 29482a3d961838dc525cd142699bc34357c8db4d17cb6ac9f99f86deb7ba5c3ab68fa302e148e943bd759a62189e08622ab77a6f62e53c7e35ac0ca1d0ef70fd diff --git a/dev-cpp/llama-cpp/llama-cpp-9999.ebuild b/dev-cpp/llama-cpp/llama-cpp-9999.ebuild new file mode 100644 index 0000000..ef4e288 --- /dev/null +++ b/dev-cpp/llama-cpp/llama-cpp-9999.ebuild @@ -0,0 +1,78 @@ +# Copyright 2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +ROCM_VERSION=5.5 + +inherit cmake llvm rocm + +LLVM_MAX_SLOT=16 + +EGIT_REPO_URI="https://github.com/ggerganov/llama.cpp.git" +inherit git-r3 + +DESCRIPTION="Port of Facebook's LLaMA model in C/C++" +HOMEPAGE="https://github.com/ggerganov/llama.cpp" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64" +IUSE="blas cublas lto tests tools rocm" +CPU_FLAGS_X86=( avx avx2 f16c ) + +DEPEND="blas? ( sci-libs/openblas:= ) + cublas? ( dev-util/nvidia-cuda-toolkit ) + rocm? ( sci-libs/rocBLAS )" +RDEPEND="${DEPEND}" +BDEPEND="${DEPEND}" + +S="${WORKDIR}/${P}" + +src_configure() { + if use rocm ; then + CC=/usr/lib/llvm/${LLVM_MAX_SLOT}/bin/clang + CXX=/usr/lib/llvm/${LLVM_MAX_SLOT}/bin/clang++ + export DEVICE_LIB_PATH=/usr/lib/amdgcn/bitcode + export HIP_DEVICE_LIB_PATH=/usr/lib/amdgcn/bitcode + fi + local mycmakeargs=( + -DLLAMA_BLAS="$(usex blas)" + -DLLAMA_CUBLAS="$(usex cublas)" + -DLLAMA_LTO="$(usex lto)" + -DLLAMA_BUILD_TESTS="$(usex tests)" + -DLLAMA_HIPBLAS="$(usex rocm)" + -DAMDGPU_TARGETS="$(get_amdgpu_flags)" + -DLLAMA_BUILD_SERVER=OFF + -DCMAKE_SKIP_BUILD_RPATH=ON + -DBUILD_NUMBER="1" + ) + if use cublas ; then + addpredict /dev/nvidiactl + fi + cmake_src_configure +} + +src_install() { + doheader llama.h + + cd "${BUILD_DIR}" || die + + dolib.so libllama.so + + newbin bin/main llama-cpp + + if use tools ; then + newbin bin/benchmark llama-cpp-benchmark + newbin bin/perplexity llama-cpp-perplexity + newbin bin/q8dot llama-cpp-q8dot + newbin bin/quantize llama-cpp-quantize + newbin bin/quantize-stats llama-cpp-quantize-stats + newbin bin/vdot llama-cpp-vdot + fi + +} + +pkg_postinst() { + elog "The main binary has been installed as \"llama-cpp\"" +} |