浏览代码

Fix CPU-only build under Android Termux enviornment.

Update gpu.go initGPUHandles() to declare gpuHandles variable before
reading it. This resolves an "invalid memory address or nil pointer
dereference" error.

Update dyn_ext_server.c to avoid setting the RTLD_DEEPBIND flag under
__TERMUX__ (Android).
Self Denial 1 年之前
父节点
当前提交
eb76f3e379
共有 2 个文件被更改,包括 2 次插入2 次删除
  1. 1 1
      gpu/gpu.go
  2. 1 1
      llm/dyn_ext_server.c

+ 1 - 1
gpu/gpu.go

@@ -63,6 +63,7 @@ func initGPUHandles() {
 
 	// TODO - if the ollama build is CPU only, don't do these checks as they're irrelevant and confusing
 
+	gpuHandles = &handles{nil, nil}
 	var cudaMgmtName string
 	var cudaMgmtPatterns []string
 	var rocmMgmtName string
@@ -87,7 +88,6 @@ func initGPUHandles() {
 	}
 
 	slog.Info("Detecting GPU type")
-	gpuHandles = &handles{nil, nil}
 	cudaLibPaths := FindGPULibs(cudaMgmtName, cudaMgmtPatterns)
 	if len(cudaLibPaths) > 0 {
 		cuda := LoadCUDAMgmt(cudaLibPaths)

+ 1 - 1
llm/dyn_ext_server.c

@@ -3,7 +3,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#ifdef __linux__
+#if defined(__linux__) && !defined(__TERMUX__)
 #include <dlfcn.h>
 #define LOAD_LIBRARY(lib, flags) dlopen(lib, flags)
 #define LOAD_SYMBOL(handle, sym) dlsym(handle, sym)