From ddbfa6fe31c4fc1894dbfdf77df53590dfdf5119 Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Wed, 3 Jan 2024 16:08:34 -0800 Subject: [PATCH] Fix CPU only builds Go embed doesn't like when there's no matching files, so put a dummy placeholder in to allow building without any GPU support If no "server" library is found, it's safely ignored at runtime. --- llm/llama.cpp/gen_linux.sh | 3 +++ llm/shim_ext_server.go | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/llm/llama.cpp/gen_linux.sh b/llm/llama.cpp/gen_linux.sh index 721e20a9..9616a3bb 100755 --- a/llm/llama.cpp/gen_linux.sh +++ b/llm/llama.cpp/gen_linux.sh @@ -35,6 +35,9 @@ BUILD_DIR="gguf/build/linux/cpu" build install +# Placeholder to keep go embed happy until we start building dynamic CPU lib variants +touch ${BUILD_DIR}/lib/dummy.so + if [ -d /usr/local/cuda/lib64/ ]; then echo "CUDA libraries detected - building dynamic CUDA library" init_vars diff --git a/llm/shim_ext_server.go b/llm/shim_ext_server.go index 96192731..9538796d 100644 --- a/llm/shim_ext_server.go +++ b/llm/shim_ext_server.go @@ -147,9 +147,9 @@ func extractDynamicLibs(workDir, glob string) ([]string, error) { if err != nil || len(files) == 0 { return nil, payloadMissing } - libs := make([]string, len(files)) + libs := []string{} - for i, file := range files { + for _, file := range files { pathComps := strings.Split(file, "/") if len(pathComps) != 7 { log.Printf("unexpected payload components: %v", pathComps) @@ -169,7 +169,7 @@ func extractDynamicLibs(workDir, glob string) ([]string, error) { destFile := filepath.Join(targetDir, filepath.Base(file)) if strings.Contains(destFile, "server") { - libs[i] = destFile + libs = append(libs, destFile) } _, err = os.Stat(destFile)