From 354d4f232fd6a9efe357e49fd8299bc4a6224b42 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Thu, 30 Mar 2023 11:55:35 +0800 Subject: [PATCH] fixed linux openblas build errors --- Makefile | 17 ++++++++++++----- llamacpp_for_kobold.py | 6 +++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 4feb5e09c..3598f698b 100644 --- a/Makefile +++ b/Makefile @@ -182,8 +182,8 @@ ifndef LLAMA_NO_ACCELERATE endif endif ifdef LLAMA_OPENBLAS - CFLAGS += -DGGML_USE_OPENBLAS -I/usr/local/include/openblas - LDFLAGS += -l:libopenblas.lib -L. + CFLAGS += -DGGML_USE_OPENBLAS -I/usr/local/include/openblas + LDFLAGS += -lopenblas endif ifdef LLAMA_GPROF CFLAGS += -pg @@ -206,6 +206,13 @@ ifneq ($(filter armv8%,$(UNAME_M)),) CFLAGS += -mfp16-format=ieee -mno-unaligned-access endif +BLAS_BUILD = +ifeq ($(OS),Windows_NT) + BLAS_BUILD = $(CXX) $(CXXFLAGS) expose.cpp ggml_blas.o common.o extra.o libopenblas.lib -shared -o llamacpp_blas.dll $(LDFLAGS) +else + BLAS_BUILD = @echo 'Your OS is $(OS) and does not appear to be Windows. If you want to use openblas, please link it manually with LLAMA_OPENBLAS=1' +endif + # # Print build information # @@ -243,7 +250,7 @@ extra.o: extra.cpp extra.h $(CXX) $(CXXFLAGS) -c extra.cpp -o extra.o clean: - rm -vf *.o main quantize perplexity embedding + rm -vf *.o main quantize perplexity embedding main.exe quantize.exe llamacpp.dll llamacpp_blas.dll main: examples/main/main.cpp ggml.o llama.o common.o $(CXX) $(CXXFLAGS) examples/main/main.cpp ggml.o llama.o common.o -o main $(LDFLAGS) @@ -255,8 +262,8 @@ llamalib: expose.cpp ggml.o common.o extra.o $(CXX) $(CXXFLAGS) expose.cpp ggml.o common.o extra.o -shared -o llamacpp.dll $(LDFLAGS) llamalib_blas: expose.cpp ggml_blas.o common.o extra.o - $(CXX) $(CXXFLAGS) expose.cpp ggml_blas.o common.o extra.o libopenblas.lib -shared -o llamacpp_blas.dll $(LDFLAGS) - + $(BLAS_BUILD) + quantize: examples/quantize/quantize.cpp ggml.o llama.o $(CXX) $(CXXFLAGS) examples/quantize/quantize.cpp ggml.o llama.o -o quantize $(LDFLAGS) diff --git a/llamacpp_for_kobold.py b/llamacpp_for_kobold.py index 987c662a3..564dddea1 100644 --- a/llamacpp_for_kobold.py +++ b/llamacpp_for_kobold.py @@ -287,7 +287,10 @@ def RunServerMultiThreaded(addr, port, embedded_kailite = None): def main(args): global use_blas if not os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), "libopenblas.dll")) or not os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), "llamacpp_blas.dll")): - print("Warning: libopenblas.dll or llamacpp_blas.dll not found. OpenBLAS will be disabled.") + print("Warning: libopenblas.dll or llamacpp_blas.dll not found. Non-BLAS library will be used. Ignore this if you have manually linked with OpenBLAS.") + use_blas = False + elif os.name != 'nt': + print("Prebuilt OpenBLAS binaries only available for windows. Please manually build/link libopenblas from makefile with LLAMA_OPENBLAS=1") use_blas = False elif not args.noblas: print("Attempting to use OpenBLAS library for faster prompt ingestion. A compatible libopenblas.dll will be required.") @@ -318,6 +321,7 @@ def main(args): if not loadok: print("Could not load model: " + modelname) + time.sleep(1) sys.exit(3) try: basepath = os.path.abspath(os.path.dirname(__file__))