Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
daed0634
Unverified
Commit
daed0634
authored
Jul 03, 2024
by
Daniel Hiltgen
Committed by
GitHub
Jul 03, 2024
Browse files
Merge pull request #5467 from dhiltgen/bogus_cpu_mac_error
Fix corner cases on tmp cleaner on mac
parents
0d4dd707
0e982bc1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
22 deletions
+37
-22
llm/payload.go
llm/payload.go
+23
-21
llm/server.go
llm/server.go
+14
-1
No files found.
llm/payload.go
View file @
daed0634
...
...
@@ -38,7 +38,7 @@ func Init() error {
}
var
variants
[]
string
for
v
:=
range
a
vailableServers
()
{
for
v
:=
range
getA
vailableServers
()
{
variants
=
append
(
variants
,
v
)
}
slog
.
Info
(
fmt
.
Sprintf
(
"Dynamic LLM libraries %v"
,
variants
))
...
...
@@ -50,7 +50,7 @@ func Init() error {
// binary names may contain an optional variant separated by '_'
// For example, "ollama_rocm_v6" and "ollama_rocm_v5" or "ollama_cpu" and "ollama_cpu_avx2"
// Any library without a variant is the lowest common denominator
func
a
vailableServers
()
map
[
string
]
string
{
func
getA
vailableServers
()
map
[
string
]
string
{
payloadsDir
,
err
:=
gpu
.
PayloadsDir
()
if
err
!=
nil
{
slog
.
Error
(
"payload lookup error"
,
"error"
,
err
)
...
...
@@ -80,7 +80,7 @@ func availableServers() map[string]string {
// TODO - switch to metadata based mapping
func
serversForGpu
(
info
gpu
.
GpuInfo
)
[]
string
{
// glob workDir for files that start with ollama_
availableServers
:=
a
vailableServers
()
availableServers
:=
getA
vailableServers
()
requested
:=
info
.
Library
if
info
.
Variant
!=
gpu
.
CPUCapabilityNone
{
requested
+=
"_"
+
info
.
Variant
.
String
()
...
...
@@ -115,27 +115,29 @@ func serversForGpu(info gpu.GpuInfo) []string {
servers
=
append
(
servers
,
alt
...
)
}
// Load up the best CPU variant if not primary requested
if
info
.
Library
!=
"cpu"
{
variant
:=
gpu
.
GetCPUCapability
()
// If no variant, then we fall back to default
// If we have a variant, try that if we find an exact match
// Attempting to run the wrong CPU instructions will panic the
// process
if
variant
!=
gpu
.
CPUCapabilityNone
{
for
cmp
:=
range
availableServers
{
if
cmp
==
"cpu_"
+
variant
.
String
()
{
servers
=
append
(
servers
,
cmp
)
break
if
!
(
runtime
.
GOOS
==
"darwin"
&&
runtime
.
GOARCH
==
"arm64"
)
{
// Load up the best CPU variant if not primary requested
if
info
.
Library
!=
"cpu"
{
variant
:=
gpu
.
GetCPUCapability
()
// If no variant, then we fall back to default
// If we have a variant, try that if we find an exact match
// Attempting to run the wrong CPU instructions will panic the
// process
if
variant
!=
gpu
.
CPUCapabilityNone
{
for
cmp
:=
range
availableServers
{
if
cmp
==
"cpu_"
+
variant
.
String
()
{
servers
=
append
(
servers
,
cmp
)
break
}
}
}
else
{
servers
=
append
(
servers
,
"cpu"
)
}
}
else
{
servers
=
append
(
servers
,
"cpu"
)
}
}
if
len
(
servers
)
==
0
{
servers
=
[]
string
{
"cpu"
}
if
len
(
servers
)
==
0
{
servers
=
[]
string
{
"cpu"
}
}
}
return
servers
...
...
@@ -147,7 +149,7 @@ func serverForCpu() string {
return
"metal"
}
variant
:=
gpu
.
GetCPUCapability
()
availableServers
:=
a
vailableServers
()
availableServers
:=
getA
vailableServers
()
if
variant
!=
gpu
.
CPUCapabilityNone
{
for
cmp
:=
range
availableServers
{
if
cmp
==
"cpu_"
+
variant
.
String
()
{
...
...
llm/server.go
View file @
daed0634
...
...
@@ -131,7 +131,20 @@ func NewLlamaServer(gpus gpu.GpuInfoList, model string, ggml *GGML, adapters, pr
return
nil
,
errors
.
New
(
"ollama supports only one lora adapter, but multiple were provided"
)
}
availableServers
:=
availableServers
()
availableServers
:=
getAvailableServers
()
if
len
(
availableServers
)
==
0
{
if
runtime
.
GOOS
!=
"windows"
{
slog
.
Warn
(
"llama server binary disappeared, reinitializing payloads"
)
err
=
Init
()
if
err
!=
nil
{
slog
.
Warn
(
"failed to reinitialize payloads"
,
"error"
,
err
)
return
nil
,
err
}
availableServers
=
getAvailableServers
()
}
else
{
return
nil
,
finalErr
}
}
var
servers
[]
string
if
cpuRunner
!=
""
{
servers
=
[]
string
{
cpuRunner
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment