fixed linux openblas build errors

This commit is contained in:
Concedo 2023-03-30 11:55:35 +08:00
parent 977a9a246f
commit 354d4f232f
2 changed files with 17 additions and 6 deletions

View file

@ -183,7 +183,7 @@ ifndef LLAMA_NO_ACCELERATE
endif
ifdef LLAMA_OPENBLAS
CFLAGS += -DGGML_USE_OPENBLAS -I/usr/local/include/openblas
LDFLAGS += -l:libopenblas.lib -L.
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,7 +262,7 @@ 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)

View file

@ -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__))