From 7dc88a40d1796e988991a148b19ac184db6469bc Mon Sep 17 00:00:00 2001 From: Jose Yukiteru Amano Date: Sat, 22 Jul 2023 16:51:48 -0400 Subject: [PATCH] Fix Makefile for CLBLAST compile support and instructions for compile llama.cpp FreeBSD --- Makefile | 12 ++++++++++-- README.md | 17 +++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1ea3c4562..4782096d8 100644 --- a/Makefile +++ b/Makefile @@ -235,8 +235,16 @@ ggml-cuda.o: ggml-cuda.cu ggml-cuda.h endif # LLAMA_CUBLAS ifdef LLAMA_CLBLAST - CFLAGS += -DGGML_USE_CLBLAST - CXXFLAGS += -DGGML_USE_CLBLAST + + # If FreeBSD system is detected and env GGML_USE_CLBLAST=1 is used, we compile llama.cpp with this support + ifeq ($(UNAME_S),FreeBSD) + CFLAGS += -DGGML_USE_CLBLAST $(shell pkg-config --cflags clblast) + CXXFLAGS += -DGGML_USE_CLBLAST $(shell pkg-config --cflags clblast) + else + CFLAGS += -DGGML_USE_CLBLAST + CXXFLAGS += -DGGML_USE_CLBLAST + endif + # Mac provides OpenCL as a framework ifeq ($(UNAME_S),Darwin) LDFLAGS += -lclblast -framework OpenCL diff --git a/README.md b/README.md index f45e4bf08..c9fe6187b 100644 --- a/README.md +++ b/README.md @@ -242,6 +242,23 @@ In order to build llama.cpp you have three different options. zig build -Doptimize=ReleaseFast ``` +- Using `gmake` (FreeBSD): + + 1. Install and activate [DRM in FreeBSD](https://wiki.freebsd.org/Graphics) + 2. Add your user to **video** group + 3. Install compilation dependencies. + + ```bash + sudo pkg install gmake automake autoconf pkgconf llvm15 clinfo clover \ + opencl clblast openblas + + gmake CC=/usr/local/bin/clang15 CXX=/usr/local/bin/clang++15 -j4 + ``` + + **Notes:** With this packages you can build llama.cpp with OPENBLAS and + CLBLAST support for use OpenCL GPU acceleration in FreeBSD. Please read + the instructions for use and activate this options in this document below. + ### Metal Build Using Metal allows the computation to be executed on the GPU for Apple devices: