Index: src/github.com/ollama/ollama/gpu/gpu.go
--- src/github.com/ollama/ollama/gpu/gpu.go.orig	2024-03-24 00:21:14.000000000 +0100
+++ src/github.com/ollama/ollama/gpu/gpu.go	2024-03-24 01:25:18.485472000 +0100
@@ -1,10 +1,11 @@
-//go:build linux || windows
+//go:build linux || windows || freebsd
 
 package gpu
 
 /*
 #cgo linux LDFLAGS: -lrt -lpthread -ldl -lstdc++ -lm
 #cgo windows LDFLAGS: -lpthread
+#cgo freebsd LDFLAGS: -lpthread -lstdc++ -lm
 
 #include "gpu_info.h"
 
@@ -122,11 +123,6 @@
 				slog.Info(fmt.Sprintf("CUDA GPU is too old. Falling back to CPU mode. Compute Capability detected: %d.%d", cc.major, cc.minor))
 			}
 		}
-	} else {
-		AMDGetGPUInfo(&resp)
-		if resp.Library != "" {
-			return resp
-		}
 	}
 	if resp.Library == "" {
 		C.cpu_check_ram(&memInfo)
Index: src/github.com/ollama/ollama/gpu/gpu_info_cpu.c
--- src/github.com/ollama/ollama/gpu/gpu_info_cpu.c.orig	2024-03-24 00:21:14.000000000 +0100
+++ src/github.com/ollama/ollama/gpu/gpu_info_cpu.c	2024-03-24 00:36:24.875470000 +0100
@@ -40,6 +40,14 @@
 //   mem_info_t resp = {0, 0, NULL};
 //   return resp;
 // }
+#elif __FreeBSD__
+void cpu_check_ram(mem_info_t *resp) {
+  resp->err   = NULL;
+  resp->count = 0;
+  resp->total = 0;
+  resp->free  = 0;
+  return;
+}
 #else
 #error "Unsupported platform"
 #endif
Index: src/github.com/ollama/ollama/llm/dyn_ext_server.c
--- src/github.com/ollama/ollama/llm/dyn_ext_server.c.orig	2024-03-24 00:21:14.000000000 +0100
+++ src/github.com/ollama/ollama/llm/dyn_ext_server.c	2024-03-24 00:36:24.875545000 +0100
@@ -3,7 +3,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD__)
 #include <dlfcn.h>
 #define LOAD_LIBRARY(lib, flags) dlopen(lib, flags)
 #define LOAD_SYMBOL(handle, sym) dlsym(handle, sym)
Index: src/github.com/ollama/ollama/llm/dyn_ext_server.go
--- src/github.com/ollama/ollama/llm/dyn_ext_server.go.orig	2024-03-24 00:21:14.000000000 +0100
+++ src/github.com/ollama/ollama/llm/dyn_ext_server.go	2024-03-24 00:36:24.875638000 +0100
@@ -13,6 +13,9 @@
 #cgo linux CFLAGS: -D_GNU_SOURCE
 #cgo linux LDFLAGS: -lrt -ldl -lstdc++ -lm
 #cgo linux windows LDFLAGS: -lpthread
+#cgo freebsd CFLAGS: -D_GNU_SOURCE
+#cgo freebsd LDFLAGS: -lstdc++ -lm
+#cgo freebsd windows LDFLAGS: -lpthread
 
 #include <stdlib.h>
 #include "dyn_ext_server.h"
Index: src/github.com/ollama/ollama/llm/generate/gen_common.sh
--- src/github.com/ollama/ollama/llm/generate/gen_common.sh.orig	2024-03-24 00:21:14.000000000 +0100
+++ src/github.com/ollama/ollama/llm/generate/gen_common.sh	2024-03-24 00:36:24.875709000 +0100
@@ -36,6 +36,14 @@
         # Cross compiling not supported on linux - Use docker
         GCC_ARCH=""
         ;;
+    "FreeBSD")
+        LIB_EXT="so"
+        WHOLE_ARCHIVE="-Wl,--whole-archive"
+        NO_WHOLE_ARCHIVE="-Wl,--no-whole-archive"
+
+        # Cross compiling not supported on linux - Use docker
+        GCC_ARCH=""
+        ;;
     *)
         ;;
     esac
Index: src/github.com/ollama/ollama/llm/generate/generate_freebsd.go
--- src/github.com/ollama/ollama/llm/generate/generate_freebsd.go.orig	2024-03-24 00:36:24.875774000 +0100
+++ src/github.com/ollama/ollama/llm/generate/generate_freebsd.go	2024-03-24 00:36:24.875767000 +0100
@@ -0,0 +1,3 @@
+package generate
+
+//go:generate bash ./gen_linux.sh
