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
16b52331
Unverified
Commit
16b52331
authored
Apr 23, 2024
by
Daniel Hiltgen
Committed by
GitHub
Apr 23, 2024
Browse files
Merge pull request #3857 from dhiltgen/mem_escape_valve
Add back memory escape valve
parents
2ac3dd68
5445aaa9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
llm/memory.go
llm/memory.go
+13
-0
No files found.
llm/memory.go
View file @
16b52331
...
@@ -3,6 +3,8 @@ package llm
...
@@ -3,6 +3,8 @@ package llm
import
(
import
(
"fmt"
"fmt"
"log/slog"
"log/slog"
"os"
"strconv"
"strings"
"strings"
"github.com/ollama/ollama/api"
"github.com/ollama/ollama/api"
...
@@ -49,6 +51,17 @@ func EstimateGPULayers(gpus []gpu.GpuInfo, ggml *GGML, projectors []string, opts
...
@@ -49,6 +51,17 @@ func EstimateGPULayers(gpus []gpu.GpuInfo, ggml *GGML, projectors []string, opts
for
_
,
info
:=
range
gpus
{
for
_
,
info
:=
range
gpus
{
memoryAvailable
+=
info
.
FreeMemory
memoryAvailable
+=
info
.
FreeMemory
}
}
userLimit
:=
os
.
Getenv
(
"OLLAMA_MAX_VRAM"
)
if
userLimit
!=
""
{
avail
,
err
:=
strconv
.
ParseUint
(
userLimit
,
10
,
64
)
if
err
!=
nil
{
slog
.
Error
(
"invalid setting, ignoring"
,
"OLLAMA_MAX_VRAM"
,
userLimit
,
"error"
,
err
)
}
else
{
slog
.
Info
(
"user override memory limit"
,
"OLLAMA_MAX_VRAM"
,
avail
,
"actual"
,
memoryAvailable
)
memoryAvailable
=
avail
}
}
slog
.
Debug
(
"evaluating"
,
"library"
,
gpus
[
0
]
.
Library
,
"gpu_count"
,
len
(
gpus
),
"available"
,
format
.
HumanBytes2
(
memoryAvailable
))
slog
.
Debug
(
"evaluating"
,
"library"
,
gpus
[
0
]
.
Library
,
"gpu_count"
,
len
(
gpus
),
"available"
,
format
.
HumanBytes2
(
memoryAvailable
))
// TODO - this is probably wrong, first GPU vs secondaries will have different overheads
// TODO - this is probably wrong, first GPU vs secondaries will have different overheads
...
...
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