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
50ee8b5f
Unverified
Commit
50ee8b5f
authored
Aug 05, 2024
by
Daniel Hiltgen
Committed by
GitHub
Aug 05, 2024
Browse files
Merge pull request #6186 from dhiltgen/numa
Implement linux NUMA detection
parents
03bdac05
f457d634
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
4 deletions
+29
-4
api/types.go
api/types.go
+0
-2
gpu/cpu_common.go
gpu/cpu_common.go
+21
-0
llm/server.go
llm/server.go
+8
-2
No files found.
api/types.go
View file @
50ee8b5f
...
@@ -231,7 +231,6 @@ type Options struct {
...
@@ -231,7 +231,6 @@ type Options struct {
// Runner options which must be set when the model is loaded into memory
// Runner options which must be set when the model is loaded into memory
type
Runner
struct
{
type
Runner
struct
{
UseNUMA
bool
`json:"numa,omitempty"`
NumCtx
int
`json:"num_ctx,omitempty"`
NumCtx
int
`json:"num_ctx,omitempty"`
NumBatch
int
`json:"num_batch,omitempty"`
NumBatch
int
`json:"num_batch,omitempty"`
NumGPU
int
`json:"num_gpu,omitempty"`
NumGPU
int
`json:"num_gpu,omitempty"`
...
@@ -615,7 +614,6 @@ func DefaultOptions() Options {
...
@@ -615,7 +614,6 @@ func DefaultOptions() Options {
F16KV
:
true
,
F16KV
:
true
,
UseMLock
:
false
,
UseMLock
:
false
,
UseMMap
:
nil
,
UseMMap
:
nil
,
UseNUMA
:
false
,
},
},
}
}
}
}
...
...
gpu/cpu_common.go
View file @
50ee8b5f
package
gpu
package
gpu
import
(
import
(
"os"
"path/filepath"
"runtime"
"strings"
"golang.org/x/sys/cpu"
"golang.org/x/sys/cpu"
)
)
...
@@ -14,3 +19,19 @@ func GetCPUCapability() CPUCapability {
...
@@ -14,3 +19,19 @@ func GetCPUCapability() CPUCapability {
// else LCD
// else LCD
return
CPUCapabilityNone
return
CPUCapabilityNone
}
}
func
IsNUMA
()
bool
{
if
runtime
.
GOOS
!=
"linux"
{
// numa support in llama.cpp is linux only
return
false
}
ids
:=
map
[
string
]
interface
{}{}
packageIds
,
_
:=
filepath
.
Glob
(
"/sys/devices/system/cpu/cpu*/topology/physical_package_id"
)
for
_
,
packageId
:=
range
packageIds
{
id
,
err
:=
os
.
ReadFile
(
packageId
)
if
err
==
nil
{
ids
[
strings
.
TrimSpace
(
string
(
id
))]
=
struct
{}{}
}
}
return
len
(
ids
)
>
1
}
llm/server.go
View file @
50ee8b5f
...
@@ -256,8 +256,14 @@ func NewLlamaServer(gpus gpu.GpuInfoList, model string, ggml *GGML, adapters, pr
...
@@ -256,8 +256,14 @@ func NewLlamaServer(gpus gpu.GpuInfoList, model string, ggml *GGML, adapters, pr
params
=
append
(
params
,
"--mlock"
)
params
=
append
(
params
,
"--mlock"
)
}
}
if
opts
.
UseNUMA
{
if
gpu
.
IsNUMA
()
{
params
=
append
(
params
,
"--numa"
)
numaMode
:=
"distribute"
if
runtime
.
GOOS
==
"linux"
{
if
_
,
err
:=
exec
.
LookPath
(
"numactl"
);
err
==
nil
{
numaMode
=
"numactl"
}
}
params
=
append
(
params
,
"--numa"
,
numaMode
)
}
}
params
=
append
(
params
,
"--parallel"
,
strconv
.
Itoa
(
numParallel
))
params
=
append
(
params
,
"--parallel"
,
strconv
.
Itoa
(
numParallel
))
...
...
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