mirror of
https://github.com/ollama/ollama.git
synced 2025-05-10 18:06:33 +02:00
* add build to .dockerignore * test: only build one arch * add build to .gitignore * fix ccache path * filter amdgpu targets * only filter if autodetecting * Don't clobber gpu list for default runner This ensures the GPU specific environment variables are set properly * explicitly set CXX compiler for HIP * Update build_windows.ps1 This isn't complete, but is close. Dependencies are missing, and it only builds the "default" preset. * build: add ollama subdir * add .git to .dockerignore * docs: update development.md * update build_darwin.sh * remove unused scripts * llm: add cwd and build/lib/ollama to library paths * default DYLD_LIBRARY_PATH to LD_LIBRARY_PATH in runner on macOS * add additional cmake output vars for msvc * interim edits to make server detection logic work with dll directories like lib/ollama/cuda_v12 * remove unncessary filepath.Dir, cleanup * add hardware-specific directory to path * use absolute server path * build: linux arm * cmake install targets * remove unused files * ml: visit each library path once * build: skip cpu variants on arm * build: install cpu targets * build: fix workflow * shorter names * fix rocblas install * docs: clean up development.md * consistent build dir removal in development.md * silence -Wimplicit-function-declaration build warnings in ggml-cpu * update readme * update development readme * llm: update library lookup logic now that there is one runner (#8587) * tweak development.md * update docs * add windows cuda/rocm tests --------- Co-authored-by: jmorganca <jmorganca@gmail.com> Co-authored-by: Daniel Hiltgen <daniel@ollama.com>
99 lines
2 KiB
Go
99 lines
2 KiB
Go
//go:build darwin
|
|
|
|
package discover
|
|
|
|
/*
|
|
#cgo CFLAGS: -x objective-c
|
|
#cgo LDFLAGS: -framework Foundation -framework CoreGraphics -framework Metal
|
|
#include "gpu_info_darwin.h"
|
|
*/
|
|
import "C"
|
|
|
|
import (
|
|
"log/slog"
|
|
"runtime"
|
|
"syscall"
|
|
|
|
"github.com/ollama/ollama/format"
|
|
)
|
|
|
|
const (
|
|
metalMinimumMemory = 512 * format.MebiByte
|
|
)
|
|
|
|
func GetGPUInfo() GpuInfoList {
|
|
mem, _ := GetCPUMem()
|
|
if runtime.GOARCH == "amd64" {
|
|
return []GpuInfo{
|
|
{
|
|
Library: "cpu",
|
|
memInfo: mem,
|
|
},
|
|
}
|
|
}
|
|
info := GpuInfo{
|
|
Library: "metal",
|
|
ID: "0",
|
|
}
|
|
info.TotalMemory = uint64(C.getRecommendedMaxVRAM())
|
|
|
|
// TODO is there a way to gather actual allocated video memory? (currentAllocatedSize doesn't work)
|
|
info.FreeMemory = info.TotalMemory
|
|
|
|
info.MinimumMemory = metalMinimumMemory
|
|
return []GpuInfo{info}
|
|
}
|
|
|
|
func GetCPUInfo() GpuInfoList {
|
|
mem, _ := GetCPUMem()
|
|
return []GpuInfo{
|
|
{
|
|
Library: "cpu",
|
|
memInfo: mem,
|
|
},
|
|
}
|
|
}
|
|
|
|
func GetCPUMem() (memInfo, error) {
|
|
return memInfo{
|
|
TotalMemory: uint64(C.getPhysicalMemory()),
|
|
FreeMemory: uint64(C.getFreeMemory()),
|
|
// FreeSwap omitted as Darwin uses dynamic paging
|
|
}, nil
|
|
}
|
|
|
|
func (l GpuInfoList) GetVisibleDevicesEnv() (string, string) {
|
|
// No-op on darwin
|
|
return "", ""
|
|
}
|
|
|
|
func GetSystemInfo() SystemInfo {
|
|
mem, _ := GetCPUMem()
|
|
query := "hw.perflevel0.physicalcpu"
|
|
perfCores, err := syscall.SysctlUint32(query)
|
|
if err != nil {
|
|
slog.Warn("failed to discover physical CPU details", "query", query, "error", err)
|
|
}
|
|
query = "hw.perflevel1.physicalcpu"
|
|
efficiencyCores, _ := syscall.SysctlUint32(query) // On x86 xeon this wont return data
|
|
|
|
// Determine thread count
|
|
query = "hw.logicalcpu"
|
|
logicalCores, _ := syscall.SysctlUint32(query)
|
|
|
|
return SystemInfo{
|
|
System: CPUInfo{
|
|
GpuInfo: GpuInfo{
|
|
memInfo: mem,
|
|
},
|
|
CPUs: []CPU{
|
|
{
|
|
CoreCount: int(perfCores + efficiencyCores),
|
|
EfficiencyCoreCount: int(efficiencyCores),
|
|
ThreadCount: int(logicalCores),
|
|
},
|
|
},
|
|
},
|
|
GPUs: GetGPUInfo(),
|
|
}
|
|
}
|